| From: | Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Best way to know if there is a row |
| Date: | 2004-09-28 12:55:23 |
| Message-ID: | 200409280955.23773.martin@bugs.unl.edu.ar |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
I have a bunch of queries in a system I'm finishing, and I bumped with a
question on performace.
Which is the best way to solve this:
I need to know if there is at least one row in the relation that comes from a
determinated query. Which is the best way to do this:
(a) Build the query with "SELECT * ..." and after executing the query see if
numRows()>0
(b) Build the query with "SELECT count(*) ...", fetch the row and see if
count>0
I'm working with (a) because I see it better in performace, but I wanted to be
sure the numRows() will actually give me the exact amount of rows (had some
problems in the past with Informix).
The aplication is written in PHP.
--
09:45:02 up 16 days, 3 min, 4 users, load average: 3.32, 2.69, 1.77
-----------------------------------------------------------------
Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica | DBA, Programador, Administrador
Universidad Nacional
del Litoral
-----------------------------------------------------------------
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Achilleus Mantzios | 2004-09-28 13:34:43 | Re: FOREIGN KEY and AccessExclusiveLock |
| Previous Message | Achilleus Mantzios | 2004-09-28 12:24:13 | Re: Best way to know if there is a row |