sql - Check number of records in a database table other than count(*) -


I want to enter a record in the table for a certain entry. I used COUNT (*) to check the number of records and got it to work However, when the number of records for a single entry is very high, then my page slowly Loads.

I think the cause of the problem is COUNT (*) , but how do I check it? Exists without using the record? I just want to check whether any entry exists for entry and then executes some code. Please help me find an alternative solution for this.

Thanks for any help.

You can work in many ways that you can use the existence, to get answers to the database To optimize the method:

  if present (select from * ...)  

You can use the top 1 so that To prevent the database after finding the first match:

  if (select count from (*) (select top 1. *) and gt; 0  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -