Optimization it takes too long to execute simple select statements

Posted on 2005-05-11
Last Modified: 2010-05-18
I am accessing two tables from a database that resides on a server different from the server I am working on.
When I run a simple select * query on these tables, Table A takes about 9 sec to return the data(9500 rows, 10 columns) the Table B takes over 2 1/2  minutes(140000 rows, 13 columns). I have to JOIN these two table, Table A has two Primary Keys and Table B has no keys defined, when I Join these two tables on the condition where the two Primary keys on Table A match the columns of same type on table B it takes over 5 minutes for the query to return the data.

Can the simple select queries be optimized for time performance?

I also ran the queries logging into the server but got the same time results!
Question by:srafi78
    LVL 28

    Expert Comment

    On Table B, create an index on those 2 fields that you use in the join.  This should speed it up a bit.
    LVL 8

    Author Comment

    Can you brief me on how to create an index? Can I create the index on the views for these tables.

    LVL 28

    Accepted Solution

    >> Can you brief me on how to create an index? <<

    CREATE INDEX <IndexName> ON <YourTable> ( <FirstColumn>, <SecondColumn>)

    >> Can I create the index on the views for these tables <<

    Yes you can but there a lot of restrictions on creating indexes on views.  You can look it up on Books Online and go to CREATE INDEX.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
    JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now