apache / apache/cloudberry

[Bug] ORCA fallbacks for collate "C"

Open
#717 3 comments 0 reactions 1 assignee Claimed by @jiaqizho View on GitHub
type: Bug type: Orca
Dominant language
C
Stars
1.4k
Forks
247
Avg merge
4d 3h
Merged PRs (30d)
39

Description

### Cloudberry Database version

_No response_

### What happened

Currently, when column attribute of table is collate "C", ORCA would fallback. We need to support it in ORCA also, because sometimes ORCA would produce better plan.

### What you think should happen instead

_No response_

### How to reproduce

```
postgres=# create table tbl(v text);
CREATE TABLE
postgres=# create table tbl_collate_c(v text collate "C");
CREATE TABLE
postgres=# explain select * from tbl order by v;
QUERY PLAN
------------------------------------------------------------------------------
Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..431.00 rows=1 width=8)
Merge Key: v
-> Sort (cost=0.00..431.00 rows=1 width=8)
Sort Key: v
-> Seq Scan on tbl (cost=0.00..431.00 rows=1 width=8)
Optimizer: Pivotal Optimizer (GPORCA)
(6 rows)

postgres=# explain select * from tbl_collate_c order by v;
QUERY PLAN
---------------------------------------------------------------------------------------
Gather Motion 3:1 (slice1; segments: 3) (cost=1451.09..2199.09 rows=52800 width=32)
Merge Key: v
-> Sort (cost=1451.09..1495.09 rows=17600 width=32)
Sort Key: v COLLATE "C"
-> Seq Scan on tbl_collate_c (cost=0.00..210.00 rows=17600 width=32)
Optimizer: Postgres query optimizer
(6 rows)
```

### Operating System

No specific

### Anything else

_No response_

### Are you willing to submit PR?

- [ ] Yes, I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://cloudberrydb.org/community/coc).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.