What is that 'eval' doing there?
That has to be detriment to performance.
No, the {BLOCK} form of eval does not contribute to any sort of detriment to performance here. Certainly not the 12 seconds that the OP is claiming (update: even eval "STRING" wouldn't explain that kind of perfomance hit).
That said, I wonder what the problem is. The OP says the delay is at execute time...I wonder if under the hood Postgres fetches the data at execute time. But that doesn't explain why the query allegedly completes quickly from the command line tool. I might also think that maybe it just doesn't finish quickly, and in the command line it just appears to start returning rows more quickly, but in the example, only 20 rows are being fetched, so it ought to be obvious whether it finishes quickly or not. I might also wonder if Postgres supports permissions on indexes, and that maybe they're not the same between how the OP is executing in the command line vs the perl program. Anyway, it's all just random speculation on my part, as I don't have the OP's system in front of me, so maybe someone else can take a better guess from the information provided, or maybe the OP can provide more information.
| [reply] |