Check Empty Memory Table
Posted by: Chuck Mongillo
Date: October 03, 2012 01:42PM
I am interested to know the fastest possible check to see if my Memory table has data or if I will need to create the data for it.
Typically you will see statements like "Select count(*) From Table" but I can't imagine counting every record is the fastest way to check that there are records.
I am wondering if I can do something like a programming shortcut. Like in an if statement (if 1=1 OR 2 = 3 ) the system does not have to look at the second part of the statement because the first part is true.
So consider : sql="SELECT 1 FROM `MyTable` WHERE count(`id`) > 0"
Edit: SELECT 1 FROM `MyTable` HAVING count(`id`) > 0
-- Group items don't work with WHERE so I changed it to HAVING, but I don't know if this would be faster. Looks like nobody is around to answer though so i'll just populate a huge table and try it to see if it's faster.
Edited 1 time(s). Last edit at 10/04/2012 11:56PM by Chuck Mongillo.
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.