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

very major performance improvement [CORE5407] #5680

Closed
firebird-automations opened this issue Nov 25, 2016 · 4 comments
Closed

very major performance improvement [CORE5407] #5680

firebird-automations opened this issue Nov 25, 2016 · 4 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Ray Holme (rholme)

Duplicates CORE1769

the below query can be very slow or very fast depending on an index

select .... from ... where bla_bla <not> in (select XXXX from YYY

if table YYY has in index with XXXX as the leading value, this query is blazingly fast,
it not and the table is significant (test case 44k rows), it is turtle slow.
I can either create an index and do the query (overall time for BOTH operations way below the original query without the index).
or
I can create another temp table with XXXX as the only column; populate it with (select distinct XXXX from YYY); index the new table on XXXX; and use the new temp table for the query.
- again MUCH faster for alll of this than the original query (seconds vs more than a minute)

---- SO

If the query optimizer sees such a query where the cardinality of the table is greater than some number (say 10) and there is no usable index,
IT SHOULD BUILD A TEMPORARY INDEX (OR LIST) FOR THE QUERY.

Perhaps an index is overkill - a simple list of distinct values (no pointers back to source record required) would be fine.

If this is done, the new temporary list or index should be kept for the duration of the transaction as it is likely that the user will follow the original query (perhaps generating a list) with another query to fix a problem (e.g. deleting orphans). Obviously if this is a list and not an index, ANY update to the original table would invalidate the list.

The extra index (list) is frequently not required and may even get in the way for normal operations, but it can make a huge difference here.

@firebird-automations
Copy link
Collaborator Author

Modified by: Ray Holme (rholme)

description: the below query can be very slow or very fast depending on an index

select .... from ... where bla_bla <not> in (select XXXX from yyy)

if tabel yyy has in index with XXXX as the leading value, this query is blazingly fast, it not and the table is significant (test case 44k rows), it is turtle slow.
I can either create an index and do the query (overall time for BOTH operations way below the original query without the index).
or
I can create another table with XXXX as the only column; populate it with (select distinct XXXX from yyy); index it; and use the new temp table for the query.
- again MUCH faster for alll of this than the original query.

---- SO

If the query optimizer sees such a query where the cardinality of the table is greater than some number (say 10) and there is no usable index,
IT SHOULD BUILD A TEMPORARY INDEX FOR THE QUERY.

=>

the below query can be very slow or very fast depending on an index

select .... from ... where bla_bla <not> in (select XXXX from YYY

if table YYY has in index with XXXX as the leading value, this query is blazingly fast,
it not and the table is significant (test case 44k rows), it is turtle slow.
I can either create an index and do the query (overall time for BOTH operations way below the original query without the index).
or
I can create another temp table with XXXX as the only column; populate it with (select distinct XXXX from YYY); index the new table on XXXX; and use the new temp table for the query.
- again MUCH faster for alll of this than the original query (seconds vs more than a minute)

---- SO

If the query optimizer sees such a query where the cardinality of the table is greater than some number (say 10) and there is no usable index,
IT SHOULD BUILD A TEMPORARY INDEX (OR LIST) FOR THE QUERY.

Perhaps an index is overkill - a simple list of distinct values (no pointers back to source record required) would be fine.

If this is done, the new temporary list or index should be kept for the duration of the transaction as it is likely that the user will follow the original query (perhaps generating a list) with another query to fix a problem (e.g. deleting orphans). Obviously if this is a list and not an index, ANY update to the original table would invalidate the list.

The extra index (list) is frequently not required and may even get in the way for normal operations, but it can make a huge difference here.

@firebird-automations
Copy link
Collaborator Author

Modified by: Sean Leyne (seanleyne)

Link: This issue duplicates CORE1769 [ CORE1769 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: Sean Leyne (seanleyne)

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Duplicate [ 3 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant