-
Notifications
You must be signed in to change notification settings - Fork 78
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
indexes are not preferred by the planner #155
Comments
hi, thanks for the report! before moving to indexes, there are a couple of things I've noticed, which might make columnar storage be a less than ideal candidate for you:
ok, now to indexes! postgres attempts to choose the best plan available for querying, and is usually right, but we can check those assumptions. you can try disabling the columnar custom scan:
this will disable the custom scan, and drop back to either a sequential scan or an index scan based on whichever postgres thinks will be faster. if it gives you a sequential scan, you can disable that as well:
that should be enough to drop you to an index scan, and you will likely see that it is no faster than not using the index (partially due to number 1 in the notes above). you can also use |
Hi there! This is somewhere between a known issue and a limitation of columnar systems. Right now we have made some effort to improve the performance of index-backed scans when indexes are used by the planner but we have not changed the planner or the columnar custom scan to make better use of indexes. As Jerry said, you can hint to the planner to force it to use an index for a given query - this is mostly a workaround for the fact that we have tuned the planner to prefer our parallel scan for most queries. As a result, indexes will be most useful for power users who want to experiment and try tuning their queries with pg_hint_plan. So in that regard, it's doing what we would expect. Generally columnar is not ideal for "needle in the haystack" queries like the one you ran (at least, I'm assuming that |
@JerrySievert Thank you very much for your reply. I have solved the problem of not being able to use indexes by using |
What's wrong?
I used two tables
public.receipts
andreader.receipts
in the test,public.receipts
is a heap table, andreader.receipts
is generated as columnar using pg_ivm. They have the samehash
indexes onaction_hash
.Then use the following query
I have noticed that queries on columnar databases are relatively slow, and the query performance is comparable to when using no indexes.
explain results
The text was updated successfully, but these errors were encountered: