On Thu, Jun 23, 2005 at 11:55:35AM -0700, Josh Berkus wrote: > Bruno, > > > I remember some discussion about delaying planning until the first > > actual query so that planning could use actual parameters to do > > the planning. If you really want to have it check the parameters > > every time, I think you will need to replan every time. I don't > > know if there is a way to save some of the prepare working while > > doing this. > > That wouldn't help much in Kurt's case. Nor in most "real" cases, which is > why I think the idea never went anywhere.
I suspect the only way to do this and have it work well would be to cache plans based on the relevant statistics of the parameters passed in. Basically, as part of parsing (which could always be cached, btw, so long as schema changes clear the cache), you store what fields in what tables/indexes each parameter corresponds to. When you go to execute you look up the stats relevant to each parameter; you can then cache plans according to the stats each parameter has. Of course caching all that is a non-trivial amount of work, so you'd only want to do it for pretty complex queries. -- Jim C. Nasby, Database Consultant [EMAIL PROTECTED] Give your computer some brain candy! www.distributed.net Team #1828 Windows: "Where do you want to go today?" Linux: "Where do you want to go tomorrow?" FreeBSD: "Are you guys coming, or what?" ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])