Monday, February 7. 2011Why the F&#% Doesn't Postgres Have Hints?!?!Trackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
s/you should expect a rapid change/you should not expect a rapid change/
When I saw the trackback, from the intro text I assumed I'd picked up some trolling. No, these are all fair comments. I don't actually have any religion here. If I thought hints were the right approach, I'd be collecting data to support why they are necessary. The funny thing about playing with the optimizer is that the more you do it, the less regular hints seem like the way around the problems you run into though.
Hinting to fix selectivity errors will need to happen at the per-column basis, in the query. Overriding there should be stable over time, as selectivity tends to stay proportionately the same even as data sets grow. That's one reason why driving hints from that angle seems better to some developers. The only way you're going to get a major change in this area is to have someone who is running into problems here fund someone to work on the relevant parts of the optimizer, with test data they can share with a few major developers. The lack of repeatable test cases for the problems people are running into is a major obstacle to doing better here.
About JOINs with aggregated results, even when a plan is weird, all my problems were solved with "WITH" clauses.
I guess that those hints were requested by people who still uses simple SQL querys from generic ORMs. Not trolling, just a comment.
Quite the opposite actually. First, most ORM users can't add query hinting even when they want to; ORM's don't support it, and if you break out of the ORM to do it, chances are you could rewrite the query for speed.
Really it's needed for folks doing complex analytical queries; those 14 pages long queries that do large amounts of aggregation across datasets. WITH queries help, but don't solve all of those problems.
As some one who was an Oracle DBA for a long time, and then worked for EnterpriseDB and now works in a large Postgres shop, I admit I found the recent thread about hinting quite entertaining.
First, let me say that hints are something you use as a last resort. They are a hard-coded directive and certainly do not scale. However, sometimes you need to make things work because the business requires it. The VP of Sales & Mkting does not really care if your database implementation is not the most elegant - they want their app to perform. I agree that "in theory" it would be great if we didn't need a lot of these features because all designs/programs were perfect, but that is just not reality. As a DBA I'd love to tell the business people we need to redesign the schema and/or rewrite the code so performance is optimal and you don't need things like hints. Or I could add a one line hint. For the business, what's a better use of resources? The difference I see between Postgres and say, Oracle, is that Postgres is a not for profit company that is not driven by customers. There are plenty of Oracle features that exist to help companies get themselves out of the messes they've gotten themselves into. It's admirable that the Postgres community wants to make the optimizer perfect instead, but Oracle has been working on the optimizer for a long time with a large group of really smart people, and I'm thinking if they haven't made it perfect, odds are the PG community isn't going to either.
Not only is Postgres community extremely unlikely to produce the "perfect optimizer", it is also very rude to tell your users that develpers consider them dumber than a computer program. Also, commercial companies should take notice of that "we're not for profit" BS. Translated to English, that means: we're not going to listen for what the users ask for, we're artists, we'll do whatever the heck we think is right.
Yes, let's do whatever all user want. (sic)
Sure, it's not good to have a huge bloated project, with bad code being constraints to good and more important features. I don't need hints. I set the right settings before the commands (http://www.postgresql.org/docs/9.0/interactive/runtime-config-query.html). Never needed more than this, just the manual.
Again, you show you're ignorance in this area. First, by admitting that you do per query planner adjustments, you are essentially admitting the query level hinting is a feature you would make use of. Second, if those tunable's are good enough for you, it shows you're not writing complex enough queries to have been affected by this; think of the case where you may want to turn off index scans for a specific subselect, but turning of all index scans is disastrous. You need a more fine grained hinting system than what the current GUC's offer.
Nice post.
I just tried to add my comments on josh's blog, but after i read your article there where some additonal thoughts in my mind: It is a pain if products are restricting functionality on purpose. Because it means that they did not consider use cases beyond their current view point. A metaphor to describe this: I sometimes face this issue with java libraries. Yes it is nice that a library owner prohibits other developers from inheriting functionalty, because it ensures that its not possible to break the intended functionality. But if you are hitting an edge case where you need to tweak some of the original intentions, you are facing the issue that it gets really hard to change something. In the end you are ending up overrideing tons of methods just because its the only way to change something because of a good reason. I guess that the same type of "problem" can be found in many scenarios and is really not unique to postgresqls query-hint problem. I think that postgresql followers are seing the problem from the wrong perspective. They always tell everyone a "we dont want it" story, but in reality they want to tell something like "sorry, we lack on manpower to implement hinting mechanics. we dont even know yet, how they should look like". The difference is subtle: In the first case, the customer is angry, because the perceived message is: "they dont want to fix it". But in the second case he has the chance to realize, that helping the pg team might be a win-win situation. (And if its just a small donation to emphase that this feature is importent for them) On the pro side: It seems like februars "query hint" discussions improved the pg faq page little bit. |
QuicksearchHi! I'm Robert Treat, COO of OmniTI, perhaps the best internet technology consulting company on the planet. A veteran open source developer and advocate, I have been recognized as a major contributor to the PostgreSQL project, and can often be found speaking on open source, databases, and large scale web operations. Recent MusingsContents of an Office
Wednesday What Todd Akin Can Teach Us About DevOps Monday Root Cause of Success Thursday You were saying?Root Cause of Success about Fri, 22.06.2012 10:18 We do postmortems when things go right - not always but we h ave, especially for big things that go right. It's im [...] Intrest free (technical) debt is risky about about Tue, 07.02.2012 05:16 Hi Robert, Tanks for your t houghtful interest in my lates t post. You are absolutely right about the underlyi [...] Blog Administration |