Skip to Content

faster alternative to where clause in SQL

Hi

Analytical Views have constraint filters that filter data before pulling the data up , The same happens with input parameters ( place holders) that filter data before pulling the data up .

Select A, B , C from tableA where A='constant' does the same function except its filters the data after its fetched , so its inefficient .

What is the SQL statement ( or CE script statement ) that places filters before pulling the data .

Rishi

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Mar 04, 2013 at 04:07 PM

    Hi Rishi,

    HANA tries to push down the filters as much as possible. You can see that from the Query plans (Visual Plan or Explain plan). So I don't think that it is inefficient.

    In case you need to use CE function to filter the data, then you can use CE_CALC with the filter like mentioned in the help documents:

    ===================================

    You create a CE_PROJECTION which uses CE_CALC to calulate the VAT rate for the

    SALES

    column.

    with_tax = CE_PROJECTION(:product, ["CID", "CNAME", "OID", "SALES",

    CE_CALC

    ('"SALES" * :vat_rate', decimal(10,2)) AS "SALES_VAT"], '"CNAME" = '':cname''');

    This is semantically equivalent to the following SQL:

    with_tax2 = SELECT cid, cname, oid, sales, sales * :vat_rate as sales_vat FROM :product WHERE cname = ':cname';

    ===================================

    Just one point, CE_CALC is really not required to perform the filter, it is just an example code.

    Regards,

    Ravi

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 05, 2013 at 07:05 AM

    Rajarshi Muhuri wrote:

    Select A, B , C from tableA where A='constant' does the same function except its filters the data after its fetched , so its inefficient .

    What makes you believe this?

    - Lars

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.