Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> count(*) vs. a cursor when determining the existing record on primary key
If you have a table with a primary key and you want to determine if a
particular primary key exists what is the fastest way to accomplish
this?
In Steve Feuerstein's great book "Oracle PL/SQL Best Practices" SQL-08: Use COUNT only when the actual number of occurrences is needed...he gives some case(s) where a cursor should be used instead of the count(*) function.
If you have a table. The table has a primary key field. If you want to test for existence of a matching primary key is it better to use the COUNT function and see if there is a match > 0 (it would always be 1 or zero)...or should a cursor be used?
Thanks,
JGK Received on Mon Jun 16 2003 - 13:18:16 CDT