Is there an order of precedence in executing SQL commands?

I have a very large database, with about 1 million users and also a large number of queries running simultaneously. Sometimes the database freezes. It only reads records (SELECT), but does not make any INSERTS nor UPDATES.

I guess the INSERTS get stuck in the spool.

Is there an order of precedence in executing these SQL commands? Does SQL server first do all SELECTS and them execute INSERTS and UPDATES?

Is there a solution for this? Basicly the INSERTs and UPDATEs are used for my Ad Server (check if the media exists, insert or update click and pageview records).
Who is Participating?
Guy Hengel [angelIII / a3]Billing EngineerCommented:
sql statements are bascially first in first out.

apart from that, if your database "freezes", it can be:
* the database is currently "growing" (extending a data or log file)
 => should be avoided by sizing the files correctly, resp adding/resizing them at low-traffic hours.

* the database has a couple of statements that are starting to lock each other
  => missing indexes?

Neil RussellTechnical Development LeadCommented:
"with about 1 million users" ?? USERS?
hmiuraAuthor Commented:
"1 million users" ... I mean registered users. Not everybody at the same time. But we have a very high number of pageviews and user interaction within the portal.
hmiuraAuthor Commented:
Thanks for your help. I'll try creating more indexes and see if it really keeps DB cool.
Rich WeisslerProfessional Troublemaker^h^h^h^h^hshooterCommented:
Just a side note -- Indexes help with READ (Select) performance, at the expense of WRITE (Update/Insert) performance.  If you add additional indexes, do not be surprised if insert/update performance gets worse.

What you might want to check is to see whether the index/updates are being blocked... (you should be able to see that in the activity monitor or the sp_who stored procedure.)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.