RE: [GENERAL] slow queries

From: "Jackson, DeJuan" <djackson(at)cpsgroup(dot)com>
To: Howie <caffeine(at)toodarkpark(dot)org>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: RE: [GENERAL] slow queries
Date: 1998-09-28 14:48:50
Message-ID: F10BB1FAF801D111829B0060971D839F432E37@cpsmail
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On Fri, 25 Sep 1998, Jackson, DeJuan wrote:
> > > seems that by creating a view ( with the query i mentioned before
> ),
> > > my
> > > queries were sped up by roughly 10 seconds... odd odd odd.
> > >
> > Not really so odd when you think of everything the backend has to do
> to
> > process a query. Parsing, planning, and optimizing (not necessarily
> in
> > that order) can be very costly. A view basically skips most of
> those
> > three steps.
>
> all thats taken out is the parsing bit. the planning and optimizing
> still
> must be done ( unless its done when the view is/was created ), yesno ?
> the view should still hit the indexes created for the underlying
> tables,
> right ?
>
Well, a view in the system is really just a stored plan. The actual
text isn't stored afaik. So, that tells me that there's a good chance
that the optimization step won't be revisited unless the view is
dropped. And since the plan is the last step of the optimization step
I'd say you bypass a good deal of code. The draw back being that if the
plan isn't redone for major table changes then the query will not be the
most efficient plan, such as adding of an index that would effect the
query or additional rows in one of the tables which would make the cost
of an index scan cheaper than a table scan.

To answer your second question; it will hit the indexes if the plan that
was stored when the view was created hit those indexes.

Browse pgsql-general by date

  From Date Subject
Next Message Jackson, DeJuan 1998-09-28 15:05:34 RE: [GENERAL] Long update query ?
Previous Message David Hartwig 1998-09-28 13:21:08 Re: [GENERAL] Long update query ?