Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I need to implement a functionality that is in line with the GEQO functionality of PostgreSQL. I understand that GEQO approach is to encode query plans as integer strings and GEQO generates these possible join sequences at random. Source : http://www.postgresql.org/docs/9.3/static/geqo-pg-intro.html

My question : how to modify the GEQO function if I definitively know the right join sequence, so that I don't have to search different join sequences. For ex., if I knew that the best way of joining the 4 relations is 4-1-3-2, I needn't have to check for other permutations.

There aren't any good materials on how GEQO is implemented in PostgreSQL. PostgreSQL only gives the overall view of the GEQO functionality but doesn't explain much.

Or could I achieve this functionality in the standard_join_search() itself without using GEQO?

Any help on this appreciated. Thanks!

share|improve this question
Copied and pasted from stackoverflow.com/q/23417479/398670 –  Craig Ringer May 2 '14 at 0:17
It sounds like you want to implement query hints. That's all well and good, but you shouldn't expect to get the change accepted in PostgreSQL core because the project community isn't what you'd call a big fan of query hints. If you're serious about this, you'll need to read quite a bit of the query planner code and you'll need to figure out how to pass your hints from the parser down through the rewriter and into the planner. I don't see a quick and simple answer here. What you want to eventually do is force a particular path choice in the planner/optimizer. –  Craig Ringer May 2 '14 at 0:20
Ah, yes they are skeptical about query hints. I have done the reading of the planner code and it seemed GEQO would be a way to minimize the changes to the existing core. I posted the question here first, but the number of people following PostgreSQL was less, so copied it to Stackoverflow. Btw, how do you create links that you have mentioned in Stackoverflow? –  user2761431 May 2 '14 at 9:46
"Share" button. I think you'll find many/most seriously interested Pg users use a sitewide search that finds stuff on dba.SE, stackoverflow, and the others too. Anyway - is that what you are trying to achieve, to implement query hints to force join ordering? If so, look into whether anyone else has already implemented it. You should also consider why you need it, why the planner is making the wrong choices in the first place. Consider producing a self-contained test case and reporting to pgsql-performance. –  Craig Ringer May 2 '14 at 11:36
There is pg_hint_plan: en.sourceforge.jp/projects/pghintplan , but i didn't use it. One dba told me that it was working on 9.2. There is also article in russian about it habrahabr.ru/post/169751 –  ckorzhik Jul 17 '14 at 20:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.