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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:48:18+00:00 2026-05-12T09:48:18+00:00

The application of the query has been changed, but the theory is the same.

  • 0

The application of the query has been changed, but the theory is the same.

4 tables:

states – list of states (index on state)
stores – stores, and the state they’re in (separate indexes on state, store)
store_orders – ties an order to a store (separate indexes on store, order)
order_statuses – has order and status (separate indexes on order, status)

I want to count how many orders are in each status for a particular state.

One query:

select os.order_status, count(os.order_status)
from stores sto, store_order so, order_statuses os
where sto.state = ‘PA’
and sto.store = so.store
and so.order = os.order
group by os.order_status

in the real application, a showplan here comes back with estimated I/O of around 500,000

But if I do:

select os.order_status, count(os.order_status)
from states sta, stores sto, store_order so, order_statuses os
where sta.state = ‘PA’
where sto.state = sta.state
and sto.store = so.store
and so.order = os.order
group by os.order_status

The I/O is estimated at around 2,000, and all I did to change the query was join the states table to the stores table, and specify the exact value in states instead of stores.

Isn’t the DBM still going to have to do the same searching of stores whether I specify an explicit value, or I join another table with that explicit value?

I’m trying to figure out why the estimated I/O is so much higher.

I’m no DBA, but trying to learn as much as I can, because I hit things like this all the time, and I’m never quite sure why.

  • 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-12T09:48:18+00:00Added an answer on May 12, 2026 at 9:48 am

    Lazy Bob, Can you please also turn IO statistics on and then add the results to the question:

    set statistics io on

    showplan by itself will not give that info as you reported in the comments

    also, please post exact working query – ideally, formatted correctly.

    Your query says “where sta.state = ‘PA’ where sto.state = sta.state ” and obviously not something you could have run

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

Sidebar

Related Questions

I'm working to develop an application that has to query at some time, a
I'm writing a query for an application that needs to list all the products
Im running this query on the same server as the web application, so SPQuery.ExpandRecurrence
The query has been canceled because the estimated cost of this query (1660) exceeds
We have an application that has been deployed to 50+ websites. Across these sites
When I start my application I get: The ConnectionString property has not been initialized.
I've a website with a voting system (like/dislike). The application has been developed by
Got an application running on AppEngine. Has been running fine for 2 years. Checked
I know this question has been asked many times before but I can't find
I'd like my application to query a csv file from a secure website. I

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.