Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6476545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:50:17+00:00 2026-05-25T06:50:17+00:00

This is my query SELECT TOP 3 guid FROM eventlog WHERE (guid > 2291399

  • 0

This is my query

 SELECT TOP 3 guid FROM eventlog 
    WHERE (guid > 2291399 AND batch_uid = -1) ORDER BY date_created ASC

I’m running this qquery inside a stored procedure cursor about 25 times. Which causes the SP to run for 10 seconds plus.

Can someone advise me where I could optimize my query ?

I have tried the following indexes

CREATE INDEX eventlog_003 ON eventlog (batch_uid,date_created,guid);
CREATE INDEX eventlog_004 ON eventlog (date_created,guid);
CREATE INDEX eventlog_005 ON eventlog (guid,batch_uid,date_created ASC);
CREATE INDEX eventlog_006 ON eventlog (batch_uid,date_created ASC,guid);

Heres some stats.

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:50:18+00:00Added an answer on May 25, 2026 at 6:50 am

    It looks like most of the time is spent doing that index scan. I found some info in this question. In short, it is better to get the database to try and do an index seek rather than a scan (a scan requiring checking of fields in the table that aren’t in the index). It looks like one way you could reduce the time taken would be to create an ascending index on guid, batch_uid and date_created.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running this query: SELECT TOP 1 [DVD Copy].[Stock No] FROM [DVD Copy] WHERE
select top 1 col1 from table1 order by CreatedOn desc This query takes 6
Take this query: SELECT * FROM MyTable WHERE MyColumn = 'SomeValue' ORDER BY SomeFakeQualifier.MyColumn
I have this query: select top(2) property_id_ref ,image_file ,property_name from property_master a inner join
I am doing this query in a stored procedure: SELECT TOP 1 [Employe] FROM
I am using this SQL query SELECT TOP 11 StockPrices.Close FROM StockPrices WHERE StockPrices.Date
I know that If I run this query select top 100 * from mytable
I have this query $query_return = database::query(SELECT * FROM tw ORDER BY time DESC);
Query: SELECT TOP 1 ReportInvoked , EmailSent FROM tblReportInvoker WHERE WebUserId = 12345 This
In this query: SELECT COUNT(*) AS UserCount, Company.* FROM Company LEFT JOIN User ON

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.