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 have a specific problem: huge amounts of Web-related data in Postgres db. The queries running against the data are often very inefficient.

But in a more general sense, I need a book that explains well the "magic" behind execution of particular SQL queries and how to refactor or rewrite them.

I mean smth like this in a book form, covering a range of issues most frequently encountered in practice: http://explainextended.com/2009/09/17/not-in-vs-not-exists-vs-left-join-is-null-oracle/

An ideal book would regard PG, but needs not to. Have you read such a book that would actually help you understand sql query execution plans and how to write efficient queries?

share|improve this question

closed as not constructive by dezso, Mark Storey-Smith, Martin Smith, Phil, ypercube Jan 23 '13 at 15:46

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

6  
What about: use-the-index-luke.com (the content is also available as a book) –  a_horse_with_no_name Jan 23 '13 at 11:09
    
@a_horse_with_no_name: woo hoo! This is VERY nice! Thanks!!! Although it is limited mostly to indexes, this is still a big chunk of what I'm looking for! Why did this thing not come up in my googling? –  mrkafk Jan 23 '13 at 11:30
2  
Well query tuning is mostly about finding the best index to support the query. You might be interested in the chapter about JOINs: use-the-index-luke.com/sql/join –  a_horse_with_no_name Jan 23 '13 at 11:33
1  
Books about optimizations I liked are "The Art of SQL" by Stephane Faroult and Peter Robson (not specific for PostgreSQL, but it's exactly about what you want) and "PostgreSQL 9.0 High Performance" by Gregory Smith. –  j.p. Jan 23 '13 at 13:01
add comment

Browse other questions tagged or ask your own question.