Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2013
    Posts
    3

    Smile Unanswered: postgresql index cost estimation

    i need to estimate the cost of index
    From documentation of postgresql, i understand
    cost_qual_eval(&index_qual_cost, indexQuals, root);
    *indexStartupCost = index_qual_cost.startup;
    *indexTotalCost = seq_page_cost * numIndexPages +
    (cpu_index_tuple_cost + index_qual_cost.per_tuple) * numIndexTuples;

    Also there is a function defined as
    void amcostestimate (PlannerInfo *root,indexOptInfo *index,List *indexQuals, RelOptInfo *outer_rel, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity,
    double *indexCorrelation);

    But i dont know how to call these c functions in sql and access these datastructures


    please help?

  2. #2
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Quote Originally Posted by sabiz View Post
    i need to estimate the cost of index
    An index itself has no "cost".

    You can only estimate the cost of using an index inside a query.

    Quote Originally Posted by sabiz View Post
    But i dont know how to call these c functions in sql and access these datastructures
    Why would you want to do that?

    The only way to actually see the cost of using an index in the context of a query is to run an explain on your query. If you need to extract that information dynamically, return the execution plan as XML or JSON which can easily be parsed.
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

  3. #3
    Join Date
    Apr 2013
    Posts
    3

    Smile index cost estimation

    ya ,i need the cost dynamically ...i need to get the parameters and analyse how this cost of indexed scan is calculated

    Using using explain analyze ,we cant understand how it is calculated
    Last edited by sabiz; 04-12-13 at 05:23. Reason: :)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •