On 07/16/2012 06:13 PM, Andy Halsall
wrote:
AFAIK SQL functions don't get cached plans - though I'm not 100% on this. They can be lots cheaper for wrapping simple operations, though. I'm just questioning why you're going immediately to PL/PgSQL - or stored procs at all. It might be a bigger hammer than you need. What sorts of operations will your application be performing? Is there any reason it can't directly use simple INSERT, UPDATE, DELETE and SELECT statements, possibly with PREPARE and EXECUTE at libpq level? If you're trying to go as fast as humanly possible in emulating an ISAM-like access model with lots of small fast accesses, PQprepare of simple S/I/U/D statements, then proper use of PQexecPrepared, is likely to be hard to beat. If you're working with ISAM-like access though, cursors may well be very helpful for you. It's a pity for your app that Pg doesn't support cursors that see changes committed after cursor creation, since these are ideal when emulating ISAM "next record" / "previous record" access models. They're still suitable for tasks where you know the app doesn't need to see concurrently modified data, though. Can you show a typical sequence of operations for your DB? Also, out of interest, are you migrating from a traditional shared-file ISAM-derived database system, or something funkier?
Write concurrency in SQLite is miserable, yeah, but you get very fast shared-access reads as a trade-off and it's much closer to your app's old DB design. It depends a lot on your workload. -- Craig Ringer |