Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

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).
0
hmiura
Asked:
hmiura
1 Solution
 
Neil RussellTechnical Development LeadCommented:
"with about 1 million users" ?? USERS?
0
 
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?

...
0
 
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.
0
 
hmiuraAuthor Commented:
Thanks for your help. I'll try creating more indexes and see if it really keeps DB cool.
0
 
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.)
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now