<p> <br>Hi,<br><br>I have one table having more than 3 millions rows with following columns:<br><br>[SITE_ID]<br><br>[USER_NAME]<br><br>[ACTIVITY_NAME]<br><br>[PAGE_TYPE]<br><br>[ACTION]<br><br>[DOC_ID]<br><br>[FROM_PAGE]<br><br>[TO_PAGE]<br><br>[ORG_NAME]<br><br>[LOG_DATE_TIME]<br><br>[SESSION_ID]<br><br>[IP]<br><br>[MACHINE_ID]<br><br><br><br>I am using 8 different queries, all thru stored procedure, to fetch data.<br><br>SITE_ID, USER_NAME, ORG_NAME and ACTION are in all queries WHERE clause.<br><br>I have created SITE_ID as non-unique clustered index and USER_NAME, ORG_NAME and ACTION as non-unique non-clustered index.<br><br>Problem is that data fetching without indexs is faster than when creating idex.<br><br>Is there any problem in index columns.<br><br>Can you please suggest me a better index plan.<br><br>I have attached the queries / column table image file. <br><br>Images file described columns called details</p><p><br><br /><img src='<img src="http://xs434.xs.to/xs434/08513/queries-columns997.jpg" mce_src="http://xs434.xs.to/xs434/08513/queries-columns997.jpg" width="941" height="301">'><br>(http://xs434.xs.to/xs434/08513/queries-columns997.jpg or <br>http://xs.to/xs.php?h=xs434&d=08513&f=queries-columns997.jpg)<br><br><br>Please help..<br><br><br>Thanks<br><br>Sharma</p>
Does the table have a unique key? If it does, then does this have a PK constraint? If there is no unique key to your table then add an INT column with identity, just so you do have a unique key. Make this (1) the PK, and (2) the clustered index.
Hi, Thanks for reply. No unique key for this table. Its a logging table. Only insert and select task. If i create a unique clustered index column will it enhance the speed. How about non-clustered index of frequent called columns. Will composite index work? Thanks
You need a PK on large tables, even if they are heaps. Only INSERTs and SELECTs? Then identity column is perfect candidate for clustered index. All the other indexes will benefit.
Can you please post 1 or 2 queries that you run against this table? Would make sense if this could be the most frequently executed ones or the most crucial ones. Guessing what the indices should be without seeing how you query the data is like a shot in the dark to me. []