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

pg_qualstat can failed to group all constant values together #13

Open
dblugeon opened this issue Mar 9, 2017 · 1 comment
Open

pg_qualstat can failed to group all constant values together #13

dblugeon opened this issue Mar 9, 2017 · 1 comment
Labels

Comments

@dblugeon
Copy link

dblugeon commented Mar 9, 2017

Hello Dalibo Team,

I think that I found an issue with pg_qualstat. I attach a scripted test and this result at the end.

When a query use one or more indexes, pgqualstat does not provide qualid or uniquequalid. This absence seems impact the result in powa-web.
Powa-web can't create explain plan because argument array is not full (we can see it with pg_qualstat_by_query).

The problem occurs when there is an index. No problem with a primary key or without indexes.

script to reproduce this issue.
test_pgqual_sql.txt

the result on my postgres
result.txt
result_pk.txt

Regards

@rjuju
Copy link
Member

rjuju commented Mar 9, 2017

Hello,

Nice catch!

Actually, the problems is that a plan containing Bitmap Index Scan on a first qual and Bitmap Heap Scan with a filter on another qual won't consider the two quals as belonging to the same one.

For some obscure reason, pg prefer to do a Bitmap Index Scan for the 1st test case (with default parameters), and an Index Scan for the second one, explaining the difference.

FTR, the problematic case in your provided test case (thanks a lot) is:

                               QUERY PLAN                                
═════════════════════════════════════════════════════════════════════════
 Bitmap Heap Scan on test  (cost=4.21..14.39 rows=1 width=24)
   Recheck Cond: (a = 0)
   Filter: (b = 1)
   ->  Bitmap Index Scan on test_a_idx  (cost=0.00..4.21 rows=8 width=0)
         Index Cond: (a = 0)

@rdunklau It looks like for Bitmap Heap Scan, we need to save the qual information related to the filter in the context and compute both while handling the lefttree? Also, I don't think that pg_qualstats does handle the recheck cond (or maybe compute it for the filter instead), which will probably give broken stats for any lossy bitmap.

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

No branches or pull requests

2 participants