Re: Cache for query plans

From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Roberto Abalde <roberto(dot)abalde(at)galego21(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Cache for query plans
Date: 2001-05-30 19:11:48
Message-ID: 200105301911.f4UJBmg07829@jupiter.us.greatbridge.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Roberto Abalde wrote:
> Hi,
>
> I need to implement a cache for query plans as part of my BSc thesis. Does
> anybody know what happened to Karel Zak's patch?

Dunno.

> I'm also looking for some comments & tips about how to implement a cache for
> query plans and how to deal with the implementation of shared memory in
> PSQL.

Query trees and -plans are only handled on the backend side.
And don't forget that dealing with such thing on the client
side, which allmost runs under clients memory control, opens
a can of worms with respect to security and other issues.
Plus it's not a psql only thing. If you want applications to
benefit from it, it has to be implemented on the libpq level.

That said, general purpose query cacheing using shared memory
must at least run the parser on each query string. It could
then build some hash key based on the querytree node
structure and hold query trees and -plans in shared memory.
If it finds a query with the same key in it's cache, it'll
take a closer look if the cached and actual query only differ
in const nodes and instead of planning/optimizing again it'll
just use the cached one. A query shouldn't make it into the
cache just at first occurence, but it's hash key does and is
subsequently counted up. Combined with some ageing and the
rest of required herbs it'll serve a good meal for some types
of applications. Thus, it has to be a per database
configurable feature.

Explicit PREPARE and EXECUTE statements (or whatever keywords
actually used) are IMHO better candidates for a per session
(backend) non-shared implementation, because how could
another client be sure that a given query identifier actually
does or doesn't exist and what querystring is/should be
associated with it?

> Greetings,
> Roberto
>
> PS: Sorry for my english :(

What's wrong with it?

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ian Lance Taylor 2001-05-30 19:22:30 Re: Support for %TYPE in CREATE FUNCTION
Previous Message Jan Wieck 2001-05-30 18:39:26 Re: Support for %TYPE in CREATE FUNCTION