151 questions
2 votes
3 answers
187 views
How can I get a list of referenced tables from a query?
I have stored queries in a table that run when I want to validate the model. I want to get a list of every table that query references so I can check if a query needs to run only if a certain table is ...
0 votes
0 answers
86 views
Spark query plan takes 5+mins to flatten 1000+ columns in spark structured streaming
I have a spark Dataframe of about ~60 columns. There are multi level structs in this schema, I have to flatten this dataframe which flattens it close ~1500 columns. The flattening logic is typical to ...
2 votes
0 answers
74 views
PostgreSQL Choosing Full Index Over Partial Index
I am using PostgreSQL 17.2 and working with the postgres_air Database. I have a very simple query: SELECT status FROM postgres_air.flight WHERE status = 'Canceled'; And the following indexes: CREATE ...
2 votes
1 answer
80 views
How to Confirm if PostgreSQL Used GEQO for a Specific Query?
How can we verify if PostgreSQL used GEQO for a specific query execution? Are there specific log entries, EXPLAIN output indicators, or planner statistics that explicitly confirm GEQO was used?" ...
2 votes
1 answer
216 views
Resolving Poor Execution Plan in SQL Server with CLR Scalar Function
Essentially, my question boils down to observing these two query plans (from SQL Server 2019): Plan using a SQL-defined scalar function. Link to plan Plan using a CLR-defined scalar function. Link ...
2 votes
1 answer
167 views
Idiomatic way to push WHERE condition through OUTER JOIN in Postgres?
I want to count occurrences of some values in 2 big tables and return a single result set. In theory, there is no difference between counting values in each table then joining the result and joining ...
2 votes
1 answer
89 views
Why does the postgres planner create an all-vs-all join for some queries and not others?
I was writing a function to process selected entries of one table, by creating entries in two other tables. The second inserted table contains a reference to the first inserted table. The plan was: ...
0 votes
1 answer
341 views
MongoDB seems to use different index than it chooses when using explain
I have a query indexes like below in a fairly large collection: field1_1: {field1: 1} field2_1: {field2: 1} field3_1: {field3: 1} When I tried to run: db.getCollection('someCollection').find({ &...
0 votes
3 answers
82 views
PostgreSQL CTE by id string is very cheap, but by id from query is very expensive
I use the id directly in the query, it has a low cost: -- Query 1. -- Nested Loop Semi Join (cost=2.27..280.78 rows=1 width=129) EXPLAIN SELECT * FROM view_companies_extra WHERE company_id iN ( ...
0 votes
1 answer
92 views
How can I tell the SQL planner that a WHERE condition in the main query should be executed in the subqueries?
I am using Postgres 14.x. I have a complex query that can be observed, next to it's EXPLAIN ANALYZE, here. select * from (select * from public.select_version_of_projects('2024-03-08T08:31:08.280Z')) ...
0 votes
0 answers
138 views
Postgres Query Planner expects 1 row for a join doing a Nested Loop Join
I'm having a performance issue when joining between 2 tables because the query planner estimates 1 row, instead of potentially thousands, and chooses to do a nested join. Some background on the query: ...
3 votes
1 answer
1k views
Vastly different query performance on GIN indexed table using different search words
Problem Text searches in a Postgres table with a simple GIN index ordered by creation timestamp have wildly different latencies based on the keyword that is being searched. While searches for frequent ...
1 vote
0 answers
49 views
Postgres order of execution in query that computes a function and locks rows
My original question: In Postgres, suppose t is a table (for simplicity we'll imagine it has a single row) and f is a function. If we do select f(t.id) from t for update, when f runs, will the row be ...
2 votes
0 answers
88 views
bad performance of postgres query if on-clause of inner-join is positioned after following left-joins
Background: Hibernate 6 creates some generated queries different than hibernate 5. In hibernate 5 a query looked like this (simplified): select * from document inner join row on document.id = ...
0 votes
1 answer
472 views
How can I update the statistics of a table in cockroachdb
In cockroachdb when I explain my query i see this root@:26257/management_console_production> explain select * from clusters; info --------------------------------...