-
Notifications
You must be signed in to change notification settings - Fork 15
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
Problems with queries using the earthdistance extension #16
Comments
Are you sure that the plans produced aren't different for some reason that you have yet to consider? There is a function exposed at the SQL level, pg_stat_plans_pprint(), which takes an SQL text, explains it and pretty-prints the plan tree. This is used by the integration tests - if you write a failing test-case, the tests produce a diff of the two plan trees that plan fingerprinting considers to be substantively different. Now, if we had two pieces of SQL that we though ought to produce the same plan (or ought to not produce something fingerprinting sees as the same plan), we could just write a test case and see where fingerprinting went wrong, or where we went wrong in our belief that the two queries ought to be considered equivalent (or not equivalent). We can't do that here though, because the differing plans are not reproducible by SQL. Ideally, you'd be able to "call pprint(plantree)" from gdb for each plan tree. That will pretty print out the tree in human readable form. We can then compare the two, and should be able to resolve the problem in that way. |
Take a look at this commit in my personal fork of pg_stat_plans: https://github.com/petergeoghegan/pg_stat_plans/commit/4c93b988df98a4650cb168b8fca9c32b51c2ba5f If you can build with this commit, it should allow you to get to the bottom of this problem (and other similar problems) without too much effort. |
Thanks for the patch - I'll test it during our next hack session and see what it comes up with! |
@terrorobe Did you ever try this? Did you conclude that this wasn't a real problem? |
I tracked down the problem, but I'm about out of steam for the night, so am not about to speculate on the exact cause just yet. When I set a breakpoint here: (gdb) bt This happens: (gdb) p *queryDesc Essentially, the explain infrastructure ends up explaining the query "SELECT '6378168'::float8" - this is obviously from this SQL from with the earthdistance extension: CREATE FUNCTION earth() RETURNS float8 I'll try and take another look at this over the week ahead. |
Peter - many thanks! We lost access to that specific database and haven't had other issues with pg_stat_plans so far. I might get access to a GIS-using database in the next few weeks, will keep you posted how it goes. |
@terrorobe So the root issue is the one I reported to pgsql-bugs, here: http://www.postgresql.org/message-id/CAM3SWZTNZBmOYvM8BOPjpts=LCWvS2j_PevEt35wOxDgayzBvA@mail.gmail.com There seems to be some confusion about just what pg_stat_statements (or, really, the core system) ought to do with SQL-function calls. I have this provisional fix, that you may wish to try out: https://github.com/petergeoghegan/pg_stat_plans/tree/fix_explain I've run the regression tests on Postgres 9.2. I've also done some minimal smoke testing by running the Postgres regression tests (make installcheck) on a cluster with pg_stat_plans installed. It would be useful if you could test this in a similar way on versions 9.0, 9.1 and 9.3. I didn't get the chance to do that today. |
@petergeoghegan I'm going to be on vacation in iceland for the next three weeks - will only find time afterwards. The best thing would be to formulate this as a regression test - do you know if there's already pgxs functionality to do testing for extensions? |
It seems as if queries using the earthdistance extension can't be explained by pg_stat_plans.
Test data set: https://gist.github.com/4665854
Tested on PostgreSQL 9.1.7 with pg_stat_plans REL1_0_STABLE
The text was updated successfully, but these errors were encountered: