2

I implemented a function to suggest movies from the example PostgreSQL database given in Seven Databases in Seven weeks.

The first attempt was correct but slow. The function could take more than 2000ms to return a result.

My second attempt was correct and much faster. I rewrote the query to make up for missed optimizations, and saw a much more efficient plan as a result. The function now takes about 10ms to return the same result.

I'd like to understand why PostgreSQL produces very different plans for these two logically equivalent queries.

Is this a good question for the dba.se format?

What should I put in a question to make the question answerable, and generally useful?

  • 3
    How about you just ask it as it is on the main site? With more technical detail. We get a fair few crap questions these days, and this is a decent one. – Philᵀᴹ Dec 3 '13 at 0:08
3

I agree with Phil.

This would be a good question if you give the details you already have and possibly even share the plans if you can.

  • Done. I executed EXPLAIN ANALYZE on the function bodies to get a detailed plan. I hope it's the right amount of detail. – Iain Samuel McLean Elder Dec 3 '13 at 23:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .