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 8476803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:16:50+00:00 2026-06-10T18:16:50+00:00

This view query is taking 2min to load 500 000 lines. I’m using EF

  • 0

This view query is taking 2min to load 500 000 lines.
I’m using EF 4.0 and thread load this view on a DataGrid.
How can I optimize it so it can load in shorter time ?

Update : I updated the query to this and now it takes 55 seconds but still too long !

SELECT  ROW_NUMBER() OVER ( ORDER BY ss.IDStore_CardStore DESC ) AS Id_PK ,
        SC.IDStockCardIndex ,
        SC.Designation ,
        ISNULL(P.PMP, 0) PMP ,
        ISNULL(SS.Quantity, 0) Quantity ,
        SS.UnitePrice * SS.Quantity AS SubTotalStockCard ,
        S.StoreName ,
        SS.IDPurchaseInvoice
FROM    dbo.Stores S
        INNER JOIN dbo.StockCardsStores ss ON S.IDStore = ss.IDStore
        RIGHT OUTER JOIN dbo.StockCard SC ON ss.IDStockCardIndex = SC.IDStockCardIndex
        LEFT OUTER JOIN ( SELECT    SUM(UnitePrice * Quantity) / SUM(Quantity) AS PMP ,
                                    IDStockCardIndex
                          FROM      dbo.StockCardsStores AS SCS
                          GROUP BY  IDStockCardIndex
                        ) AS P ON P.IDStockCardIndex = SC.IDStockCardIndex
  • 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-06-10T18:16:52+00:00Added an answer on June 10, 2026 at 6:16 pm

    Use Estimate Execution Plan in SSMS. If you’re using 2008 R2, SSMS will suggest “missing index” that will possibly improve the time overall. 500,000 rows at 55 seconds suggest that one or more table scans are kicking in. The Estimated Execution Plan will identify these. The Plan will also show what part of the query “costs” the most overall, helping you to zero in.

    Highlight that inner sub-query and look at the plan for that first. Then work your way outwards.

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

Sidebar

Related Questions

How can i dynamically load a Partial View? I mean I have this view,
Using VB.NET Using DatagridView, In a Datagrid View values are displaying like this ID
This is my query, CREATE VIEW employee_vu AS( SELECT employee_id,last_name employee,department_id FROM employees); I
How can I achieve this view with CSS: ------------------TITLE or TITLE------------------ I have <div
I have this view @model IEnumerable<ViewModelRound2> ... <snip> ... @{ using (Html.BeginForm(new { round1Ring3Bids
this is taking me too long to figure out. I am using Codeigniter to
This problem is similar to my previously asked question. When I query data using
Running Postres 7.4 (yep upgrading) This is a view query and it's used a
I've created this view that is painfully slow to query and creating performance issues.
def mysearch(request): This view builds a Q object query based on which fields are

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.