Using Cursors in PHP
am 06.08.2003 14:59:22 von Andreas Schmitz
Hello *,
I am just wondering if it is possible to use cursors within PHP. I need t=
o=20
page query result from a big table and I am looking for a solution to avo=
id=20
scanning the complete table using limit and offset.
any ideas ?
best regards
-andreas
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if you=
r
joining column's datatypes do not match
Re: Using Cursors in PHP
am 06.08.2003 17:51:21 von Scott Marlowe
On Wed, 6 Aug 2003, Andreas Schmitz wrote:
>
> Hello *,
>
> I am just wondering if it is possible to use cursors within PHP. I need to
> page query result from a big table and I am looking for a solution to avoid
> scanning the complete table using limit and offset.
Yes, you can use cursors, no you can't expect them to survive from one
page to the next.
Luckily, Postgresql is smart enough to use indexes when you use offset
limit, but, of course, it must internally create the result set up to and
including the last row returned by the limit / offset.
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly
Re: Using Cursors in PHP
am 08.08.2003 10:01:40 von Markus Bertheau
--=-SA/wsgPOaBxZd54wAnFm
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
РСÑд, 06.08.2003, в 17:51, scott.marlowe п=
иÑеÑ:
> On Wed, 6 Aug 2003, Andreas Schmitz wrote:
>=20
> >=20
> > Hello *,
> >=20
> > I am just wondering if it is possible to use cursors within PHP. I need=
to=20
> > page query result from a big table and I am looking for a solution to a=
void=20
> > scanning the complete table using limit and offset.
>=20
> Yes, you can use cursors, no you can't expect them to survive from one=20
> page to the next.
What about the new feature in cursors "WITH HOLD"? Don't they survive?
--=20
Markus Bertheau
--=-SA/wsgPOaBxZd54wAnFm
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: =?koi8-r?Q?üÔ=C1?= =?koi8-r?Q?_ÞÁÓÔ=D8?=
=?koi8-r?Q?_ÓÏÏÂÝÅÎÉ=D1?=
=?koi8-r?Q?_ÐÏÄÐÉÓÁÎ=C1?=
=?koi8-r?Q?_ÃÉÆÒÏ×ÏÊ?=
=?koi8-r?Q?_ÐÏÄÐÉÓØÀ?=
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQA/M1jkZ+yN9zLmHSMRAj0cAJ4xhJbi/WDGA2D55srv3Oy69H/PzwCe Nfdo
egG0RqegyAp3YoOBXij1c6o=
=RliO
-----END PGP SIGNATURE-----
--=-SA/wsgPOaBxZd54wAnFm--
Re: Using Cursors in PHP
am 08.08.2003 15:22:18 von Scott Marlowe
On 8 Aug 2003, Markus Bertheau wrote:
> РСÑд, 06.08.2003, в 17:51, scott.marlowe п=
иÑеÑ:
> > On Wed, 6 Aug 2003, Andreas Schmitz wrote:
> >=20
> > >=20
> > > Hello *,
> > >=20
> > > I am just wondering if it is possible to use cursors within PHP. I =
need to=20
> > > page query result from a big table and I am looking for a solution =
to avoid=20
> > > scanning the complete table using limit and offset.
> >=20
> > Yes, you can use cursors, no you can't expect them to survive from on=
e=20
> > page to the next.
>=20
> What about the new feature in cursors "WITH HOLD"? Don't they survive?
I don't think so. Basically, PHP is supposed to reset the connection if=20
it's persistant, and if it isn't persistant, then it's always a new=20
connection, which means a cursor shouldn't survive.=20
But I'm NOT familiar with "WITH HOLD" right now, so someone else who know=
s=20
that better may have a more definitive answer.
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
Re: Using Cursors in PHP
am 08.08.2003 15:33:25 von Scott Marlowe
On Fri, 8 Aug 2003, Rod Taylor wrote:
> > I don't think so. Basically, PHP is supposed to reset the connection if
> > it's persistant, and if it isn't persistant, then it's always a new
> > connection, which means a cursor shouldn't survive.
> >
> > But I'm NOT familiar with "WITH HOLD" right now, so someone else who knows
> > that better may have a more definitive answer.
>
> Yup.. This is where you setup a little Java to deal with persistent
> database elements like this and hook into it via PHP. It's a little
> nasty at the moment (though functional) but is supposedly greatly
> improved in PHP 5.
>
> http://ca2.php.net/manual/en/ref.java.php
Java providing connection pooling for PHP. Sweet!
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
Re: Using Cursors in PHP
am 08.08.2003 15:42:11 von Rod Taylor
--=-1n/BlE+rBPLScSqG8UUo
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
> I don't think so. Basically, PHP is supposed to reset the connection if=
=20
> it's persistant, and if it isn't persistant, then it's always a new=20
> connection, which means a cursor shouldn't survive.=20
>=20
> But I'm NOT familiar with "WITH HOLD" right now, so someone else who know=
s=20
> that better may have a more definitive answer.
Yup.. This is where you setup a little Java to deal with persistent
database elements like this and hook into it via PHP. It's a little
nasty at the moment (though functional) but is supposedly greatly
improved in PHP 5.
http://ca2.php.net/manual/en/ref.java.php
--=-1n/BlE+rBPLScSqG8UUo
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)
iD8DBQA/M6iy6DETLow6vwwRAoUQAJ9r6VM53cADjvZcFwf2+444Z+P49QCf T+KZ
BrAt3f6x4xl9b5oO95M/B74=
=bIP9
-----END PGP SIGNATURE-----
--=-1n/BlE+rBPLScSqG8UUo--
Re: Using Cursors in PHP
am 08.08.2003 19:34:43 von Bruce Momjian
scott.marlowe wrote:
> On 8 Aug 2003, Markus Bertheau wrote:
>
> > ?? ??????, 06.08.2003, ?? 17:51, scott.marlowe ??????????:
> > > On Wed, 6 Aug 2003, Andreas Schmitz wrote:
> > >
> > > >
> > > > Hello *,
> > > >
> > > > I am just wondering if it is possible to use cursors within PHP. I need to
> > > > page query result from a big table and I am looking for a solution to avoid
> > > > scanning the complete table using limit and offset.
> > >
> > > Yes, you can use cursors, no you can't expect them to survive from one
> > > page to the next.
> >
> > What about the new feature in cursors "WITH HOLD"? Don't they survive?
>
> I don't think so. Basically, PHP is supposed to reset the connection if
> it's persistant, and if it isn't persistant, then it's always a new
> connection, which means a cursor shouldn't survive.
Actually, that brings up a problem --- our RESET ALL doesn't close
cursors that are kept open using WITH HOLD.
However, you are right that you can't be sure you will get the same
backend when you connect via a new page, so WITH HOLD doesn't help here.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org