Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YSQL] Re-evaluate the constant trimming optimization #26120

Open
1 task done
pao214 opened this issue Feb 19, 2025 · 0 comments
Open
1 task done

[YSQL] Re-evaluate the constant trimming optimization #26120

pao214 opened this issue Feb 19, 2025 · 0 comments
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/medium Medium priority issue status/awaiting-triage Issue awaiting triage

Comments

@pao214
Copy link
Contributor

pao214 commented Feb 19, 2025

Jira Link: DB-15447

Description

Re-evaluate the below optimziation. Do we gain much from the below optimization.


CREATE TABLE th(h1 INT, h2 INT, r1 INT, PRIMARY KEY(h1 HASH, h2 HASH, r1 ASC);

Query

EXPLAIN
SELECT DISTINCT h1, h2 FROM th WHERE r1 = 1;

has a prefix length of 3

                                  QUERY PLAN                                  
------------------------------------------------------------------------------
 Distinct Index Scan using th_pkey on th  (cost=0.00..23.80 rows=200 width=8)
   Distinct Keys: h1, h2, r1
   Storage Filter: (r1 = 1)
(3 rows)

because inserting values

INSERT INTO th VALUES (0, 0, 0), (0, 0, 1);

Should return 1 row. And the query returns 0 rows with prefix length 2.


After #17741 is resolved, we should push down a prefix length of 2 in the above case.

This also allows us to remove the need for using get_op_opfamily_strategy in yb_is_const_clause_for_distinct_pushdown function. Since get_op_opfamily_strategy can lead to negative caching issues, this removal is desirable.

Issue Type

kind/bug

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.
@pao214 pao214 added area/ysql Yugabyte SQL (YSQL) status/awaiting-triage Issue awaiting triage labels Feb 19, 2025
@yugabyte-ci yugabyte-ci added kind/bug This issue is a bug priority/medium Medium priority issue labels Feb 19, 2025
@pao214 pao214 changed the title [YSQL] Remove constants specified storage filters from the distinct prefix [YSQL] Re-evaluate the constant trimming optimization Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/medium Medium priority issue status/awaiting-triage Issue awaiting triage
Projects
None yet
Development

No branches or pull requests

2 participants