Query Selectivity Computation

  • Hi friends,

    I m executing different queries with different parameter values from my application.

    How to compute selectivity of a query with particular parameter?

  • gaurangtalwadkar (5/6/2010)


    Hi friends,

    I m executing different queries with different parameter values from my application.

    How to compute selectivity of a query with particular parameter?

    distinct_values_count / all_values_count

    ---------------------------------------
    Thorn Bird...

  • I want to know whether der is any in-built function in SQL Server which gives selectivity of the query when the query is executed.

  • A query is not selective or not. The data it is accessing may or may not be selective. I don't understand where you're trying to go with this.

    You can query statistics and indexes to determine the selectivity of the underlying data. Is that what you're looking for?

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Hi everybody,

    how can I get query selectivity estimation in Sql server?

    I m executing query from C# application where I have provide text editor to write sql queries.

  • I still don't understand what you're asking for? A query has no selectivity. There is not a measured set of uniquely identifying data about a query. The data stored in tables and indexes have selectivity. You're going to have to better define what it is that you're looking for in order to get a specific answer.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • he had a similar thread on this;

    i think the original poster is trying to get a formula like (#records matching my WHERE clause) / Total Records, but he thinks it is stored in the statistics of the server?

    That's not the same as the statistics kept in SQL Server, and would vary for every query with a different WHERE statmenet.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply