Обсуждение: fastest way to retrieve data

Поиск
Список
Период
Сортировка

fastest way to retrieve data

От
Ric Mañalac
Дата:
hi,

is there a faster way to retrieve data from postgresql
using php aside from the conventional way of looping
through the number of records returned by pg_num_rows
then executing pg_fetch_row on each iteration? isn't it
possible to get the entire result set returned by pg_exec
and save that to a multi-dimensional array? this way
the program can disconnect from the db and just get
the data from the multi-dimensional array. this would also
shorten the number of requests to postgresql.

would appreaciate any suggestions. thanks!

regards,

--
Ric Mañalac

http://www.webphilippines.com
http://www.trabaho.com
http://www.kasal.com

Note:

The information contained in this message may be privileged and
confidential and protected from disclosure. If the reader of this
message is not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, you
are hereby notified that any dissemination, distribution or copying of
this communication is strictly prohibited. If you have received this
communication in error, please notify us immediately by replying to
the message and deleting it from your computer. Thank you.



Re: fastest way to retrieve data

От
"Christopher Kings-Lynne"
Дата:
Remember that looping over a result set doesn't require a 'connection' to
the server, the result is cached in the libpq library space...

Also, building an array will mean it will suck down heaps of extra RAM.  I
suggest that you don't actually have a problem, and doing it the way you're
currently doing it is the fastest way.

Chris

> -----Original Message-----
> From: pgsql-php-owner@postgresql.org
> [mailto:pgsql-php-owner@postgresql.org]On Behalf Of Ric Mañalac
> Sent: Wednesday, 4 September 2002 11:25 AM
> To: pgsql-php@postgresql.org
> Subject: [PHP] fastest way to retrieve data
> Importance: High
>
>
> hi,
>
> is there a faster way to retrieve data from postgresql
> using php aside from the conventional way of looping
> through the number of records returned by pg_num_rows
> then executing pg_fetch_row on each iteration? isn't it
> possible to get the entire result set returned by pg_exec
> and save that to a multi-dimensional array? this way
> the program can disconnect from the db and just get
> the data from the multi-dimensional array. this would also
> shorten the number of requests to postgresql.
>
> would appreaciate any suggestions. thanks!
>
> regards,
>
> --
> Ric Mañalac
>
> http://www.webphilippines.com
> http://www.trabaho.com
> http://www.kasal.com
>
> Note:
>
> The information contained in this message may be privileged and
> confidential and protected from disclosure. If the reader of this
> message is not the intended recipient, or an employee or agent
> responsible for delivering this message to the intended recipient, you
> are hereby notified that any dissemination, distribution or copying of
> this communication is strictly prohibited. If you have received this
> communication in error, please notify us immediately by replying to
> the message and deleting it from your computer. Thank you.
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>


Re: fastest way to retrieve data

От
Ric Mañalac
Дата:
thanks chris. a colleague of mine is having a hard time with her
queries. they usually take a long time to load. she's doing a lot
of complicated queries across multiple tables and return them
to HTML tables. do you have other tips to speed things up?
thank you very much for the help.

ric

Christopher Kings-Lynne wrote:

> Remember that looping over a result set doesn't require a 'connection' to
> the server, the result is cached in the libpq library space...
>
> Also, building an array will mean it will suck down heaps of extra RAM.  I
> suggest that you don't actually have a problem, and doing it the way you're
> currently doing it is the fastest way.
>
> Chris
>
> > -----Original Message-----
> > From: pgsql-php-owner@postgresql.org
> > [mailto:pgsql-php-owner@postgresql.org]On Behalf Of Ric Mañalac
> > Sent: Wednesday, 4 September 2002 11:25 AM
> > To: pgsql-php@postgresql.org
> > Subject: [PHP] fastest way to retrieve data
> > Importance: High
> >
> >
> > hi,
> >
> > is there a faster way to retrieve data from postgresql
> > using php aside from the conventional way of looping
> > through the number of records returned by pg_num_rows
> > then executing pg_fetch_row on each iteration? isn't it
> > possible to get the entire result set returned by pg_exec
> > and save that to a multi-dimensional array? this way
> > the program can disconnect from the db and just get
> > the data from the multi-dimensional array. this would also
> > shorten the number of requests to postgresql.
> >
> > would appreaciate any suggestions. thanks!
> >
> > regards,
> >
> > --
> > Ric Mañalac
> >
> > http://www.webphilippines.com
> > http://www.trabaho.com
> > http://www.kasal.com
> >
> > Note:
> >
> > The information contained in this message may be privileged and
> > confidential and protected from disclosure. If the reader of this
> > message is not the intended recipient, or an employee or agent
> > responsible for delivering this message to the intended recipient, you
> > are hereby notified that any dissemination, distribution or copying of
> > this communication is strictly prohibited. If you have received this
> > communication in error, please notify us immediately by replying to
> > the message and deleting it from your computer. Thank you.
> >
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 6: Have you searched our list archives?
> >
> > http://archives.postgresql.org
> >

--
Ric Mañalac
Head, Web Applications
Head, Design
Web Philippines, Inc.

http://www.webphilippines.com
http://www.trabaho.com
http://www.kasal.com

Note:

The information contained in this message may be privileged and
confidential and protected from disclosure. If the reader of this
message is not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, you
are hereby notified that any dissemination, distribution or copying of
this communication is strictly prohibited. If you have received this
communication in error, please notify us immediately by replying to
the message and deleting it from your computer. Thank you.



Re: fastest way to retrieve data

От
"Christopher Kings-Lynne"
Дата:
Hi Ric,

Try posting the actual slow query to the pgsql-sql mailing list and we can
all help you.

Try the usual speed tricks:

- ANALYZE
- VACUUM
- EXPLAIN ANALYZE
- CREATE INDEX
- REINDEX

Chris

> -----Original Message-----
> From: Ric Mañalac [mailto:ric.manalac@webphilippines.com]
> Sent: Wednesday, 4 September 2002 11:52 AM
> To: Christopher Kings-Lynne
> Cc: pgsql-php@postgresql.org
> Subject: Re: [PHP] fastest way to retrieve data
>
>
> thanks chris. a colleague of mine is having a hard time with her
> queries. they usually take a long time to load. she's doing a lot
> of complicated queries across multiple tables and return them
> to HTML tables. do you have other tips to speed things up?
> thank you very much for the help.
>
> ric
>
> Christopher Kings-Lynne wrote:
>
> > Remember that looping over a result set doesn't require a
> 'connection' to
> > the server, the result is cached in the libpq library space...
> >
> > Also, building an array will mean it will suck down heaps of
> extra RAM.  I
> > suggest that you don't actually have a problem, and doing it
> the way you're
> > currently doing it is the fastest way.
> >
> > Chris
> >
> > > -----Original Message-----
> > > From: pgsql-php-owner@postgresql.org
> > > [mailto:pgsql-php-owner@postgresql.org]On Behalf Of Ric Mañalac
> > > Sent: Wednesday, 4 September 2002 11:25 AM
> > > To: pgsql-php@postgresql.org
> > > Subject: [PHP] fastest way to retrieve data
> > > Importance: High
> > >
> > >
> > > hi,
> > >
> > > is there a faster way to retrieve data from postgresql
> > > using php aside from the conventional way of looping
> > > through the number of records returned by pg_num_rows
> > > then executing pg_fetch_row on each iteration? isn't it
> > > possible to get the entire result set returned by pg_exec
> > > and save that to a multi-dimensional array? this way
> > > the program can disconnect from the db and just get
> > > the data from the multi-dimensional array. this would also
> > > shorten the number of requests to postgresql.
> > >
> > > would appreaciate any suggestions. thanks!
> > >
> > > regards,
> > >
> > > --
> > > Ric Mañalac
> > >
> > > http://www.webphilippines.com
> > > http://www.trabaho.com
> > > http://www.kasal.com
> > >
> > > Note:
> > >
> > > The information contained in this message may be privileged and
> > > confidential and protected from disclosure. If the reader of this
> > > message is not the intended recipient, or an employee or agent
> > > responsible for delivering this message to the intended recipient, you
> > > are hereby notified that any dissemination, distribution or copying of
> > > this communication is strictly prohibited. If you have received this
> > > communication in error, please notify us immediately by replying to
> > > the message and deleting it from your computer. Thank you.
> > >
> > >
> > >
> > > ---------------------------(end of
> broadcast)---------------------------
> > > TIP 6: Have you searched our list archives?
> > >
> > > http://archives.postgresql.org
> > >
>
> --
> Ric Mañalac
> Head, Web Applications
> Head, Design
> Web Philippines, Inc.
>
> http://www.webphilippines.com
> http://www.trabaho.com
> http://www.kasal.com
>
> Note:
>
> The information contained in this message may be privileged and
> confidential and protected from disclosure. If the reader of this
> message is not the intended recipient, or an employee or agent
> responsible for delivering this message to the intended recipient, you
> are hereby notified that any dissemination, distribution or copying of
> this communication is strictly prohibited. If you have received this
> communication in error, please notify us immediately by replying to
> the message and deleting it from your computer. Thank you.
>
>