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] Catalog cache misses for <> operator on pkey/indexed columns #26311

Open
1 task done
m-iancu opened this issue Mar 7, 2025 · 0 comments
Open
1 task done

[YSQL] Catalog cache misses for <> operator on pkey/indexed columns #26311

m-iancu opened this issue Mar 7, 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

@m-iancu
Copy link
Contributor

m-iancu commented Mar 7, 2025

Jira Link: DB-15658

Description

lsm does not support pushing down the <> (or !=) operator but the planner will try to check if it exists in pg_amop. Also looks like we do not enable negative caching (caching for not-found lookups) for pg_amop so this will be checked each time the planner tries to plan this query.
Mitigations could be to use prepared statements to avoid re-planning each time or rewriting the query to avoid that operator (e.g. k > ? OR k < ?).

Minimal repro:

  1. Setup
CREATE TABLE test(k text primary key);
SELECT * FROM test WHERE k <> 'a';  
-- ^this should normally load whatever catalog entries this query needs in the cache

SET yb_debug_log_catcache_events = TRUE;
SET client_min_messages=LOG;
  1. Now run the query repeatedly -- the cache miss will happen each time.
SELECT * FROM test WHERE k <> 'a';
SELECT * FROM test WHERE k <> 'a';
SELECT * FROM test WHERE k <> 'a';
SELECT * FROM test WHERE k <> 'a';

Local output:

yugabyte=# SELECT * FROM test WHERE k <> 'a';
LOG:  Catalog cache miss on cache with id 3:
Target rel: pg_amop (oid : 2602), index oid 2654
Search keys: 531, s, 9922
 k
---
(0 rows)

yugabyte=# SELECT * FROM test WHERE k <> 'a';
LOG:  Catalog cache miss on cache with id 3:
Target rel: pg_amop (oid : 2602), index oid 2654
Search keys: 531, s, 9922
 k
---
(0 rows)

yugabyte=# SELECT * FROM test WHERE k <> 'a';
LOG:  Catalog cache miss on cache with id 3:
Target rel: pg_amop (oid : 2602), index oid 2654
Search keys: 531, s, 9922
 k
---
(0 rows)

yugabyte=# SELECT * FROM test WHERE k <> 'a';
LOG:  Catalog cache miss on cache with id 3:
Target rel: pg_amop (oid : 2602), index oid 2654
Search keys: 531, s, 9922
 k
---
(0 rows)

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.
@m-iancu m-iancu added area/ysql Yugabyte SQL (YSQL) status/awaiting-triage Issue awaiting triage labels Mar 7, 2025
@yugabyte-ci yugabyte-ci added kind/bug This issue is a bug priority/medium Medium priority issue labels Mar 7, 2025
@m-iancu m-iancu changed the title [YSQL] Catalog cache misses for <> operator on indexed columns [YSQL] Catalog cache misses for <> operator on pkey/indexed columns Mar 7, 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