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
Temporary Indexes to optimize some occasional query [CORE3975] #4308
Comments
Commented by: Ann Harrison (awharrison) I would want a more specific use case than "some queries run to[o] long without index before initiating an operation as expensive as index creation for a temporary object. |
Commented by: Sean Leyne (seanleyne) Given that an index requires a full scan of a table, an expensive operation, I don't see any benefit of temporary indexes. The cost of the full scan will likely be more expensive then the base query. |
Commented by: @livius2 //Given that an index requires a full scan of a table, an expensive operation, I don't see any benefit of temporary indexes. The cost of the full scan will likely be more expensive then the base query. 2. Simple scenario - this is only simplification but this show some case You have table like DEP_ID Integer, CREATE INDEX IXA_TEST__XXX ON TEST(DEP_ID, YEAR, NR); normally you run query like and to check if data in both systems are corelated you run query if you run this query many times then in all query you got table scan {really partial index scan} very expensive and in this scenario e.g. 1 query with table scan run in 1 minute 3. Think also about queries with ocassional join |
Commented by: Sean Leyne (seanleyne) 1 - But why is it necessary to define a *temporary* index? create a permanent index. The cost of maintaining the index is not that significant. 2 - What would be the context/visibility of the *temporary* index? 3 - You can do what you want, today, by defining an index, using it and then deleting it. 4 - If the order of your index was DEP_ID, NR and then YEAR, your sample query would take signigicantly less time. The optimizer would use the first 2 part of the index for narrowing/reducing the scope of the "partial scan". |
Commented by: @livius2 1 - But why is it necessary to define a *temporary* index? create a permanent index. The cost of maintaining the index is not that significant. 2 - What would be the context/visibility of the *temporary* index? 3 - You can do what you want, today, by defining an index, using it and then deleting it. 4 - If the order of your index was DEP_ID, NR and then YEAR, your sample query would take signigicantly less time. The optimizer would use the first 2 part of the index for narrowing/reducing the scope of the "partial scan". |
Submitted by: @livius2
Will be good to see feature to create temporary indexes for some query
Sometimes permanent index is not good and can slowdown inserts and other operations
but some query without index can run to long without index
this can be don in two ways
1. explicit creation of temporary index by user request
like CREATE TEMPORARY INDEX TIDX_TEST__XXX ON TEST(XXX) [ON COMMIT {DELETE | PRESERVE}];
2. automatic by engine look at this in IBM
http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=%2Frzajq%2Frzajqtempindex.htm
The text was updated successfully, but these errors were encountered: