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

  • Home
  • SEARCH
  • 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 8848937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:31:18+00:00 2026-06-14T12:31:18+00:00

I am trying to optimize the following query: SELECT tickstime AS time, quantity1 AS

  • 0

I am trying to optimize the following query:

 SELECT   tickstime AS time,
          quantity1 AS turnover
    FROM   cockpit_test.ticks
   WHERE   date_id BETWEEN 20111104 AND 20111109 
     AND   mdc_id IN (297613)
ORDER BY   time;

It is pretty simple but it takes about 60-90 seconds to run. cockpit_test.TICKS table contains more than 100M of rows. It also has an index by MDC_ID and DATE_ID columns.

EXPLAIN PLAN gives the following output

"-------------------------------------------------------------------------------------------------------"
"| Id  | Operation                    | Name           | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |"
"-------------------------------------------------------------------------------------------------------"
"|   0 | SELECT STATEMENT             |                | 26905 |   604K|       | 11783   (1)| 00:02:22 |"
"|   1 |  SORT ORDER BY               |                | 26905 |   604K|   968K| 11783   (1)| 00:02:22 |"
"|   2 |   TABLE ACCESS BY INDEX ROWID| TICKS          | 26905 |   604K|       | 11596   (1)| 00:02:20 |"
"|*  3 |    INDEX RANGE SCAN          | TICKS_MDC_DATE | 26905 |       |       |    89   (0)| 00:00:02 |"
"-------------------------------------------------------------------------------------------------------"
" "
"Predicate Information (identified by operation id):"
"---------------------------------------------------"
" "
"   3 - access(""MDC_ID""=297613 AND ""DATE_ID"">=20111104 AND ""DATE_ID""<=20111109)"

So I am not completely sure what all that means, but it seems that index is being hit and most time is being consumed by accessing rows by index rowid.

Are there any ways to make this query run faster?

UPD

Here is the table definition:

Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
DATE_ID                                   NOT NULL NUMBER(38)
MDC_ID                                    NOT NULL NUMBER(38)
TICKSTIME                                 NOT NULL DATE
STATE                                     NOT NULL NUMBER(38)
VALUE1                                    NOT NULL FLOAT(126)
VALUE2                                             FLOAT(126)
VOLUME1                                            FLOAT(126)
VOLUME2                                            FLOAT(126)
QUANTITY1                                          NUMBER(38)
QUANTITY2                                          NUMBER(38)

There are 3 indexes on the table:

  • Index on MDC_ID
  • Compound index on DATE_ID, MDC_ID, TICKSTIME
  • Compound index on DATE_ID, MDC_ID
  • 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-06-14T12:31:19+00:00Added an answer on June 14, 2026 at 12:31 pm

    I would check that this explain plan has accurate estimations of the cardinalities. It’s quite typical for the cardinality to poorly estimated when multiple predicates are supplied, and the execution time seems very high for such a small query and estimated sort size (unless you have grossly underpowered storage infrastructure, which again is pretty typical).

    Given the duration of the query I’d make sure that the estimate is accurate by invoking dynamic sampling …

    SELECT
      /*+ dynamic_sampling(4) */
      tickstime AS time,
      quantity1 AS turnover
    FROM
      cockpit_test.ticks
    WHERE
      date_id BETWEEN 20111104 AND 20111109 and
      mdc_id IN (297613)
    ORDER BY
     tickstime;
    

    If it turns out that the estimated temp space is smaller than realtiy (and you can check that by querying V$SQL_WORKAREA_ACTIVE) then you might have to tweak the memory settings for the session to switch to automatic memory management and increase the sort area size.

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

Sidebar

Related Questions

I am trying to optimize the following modified MySQL query from OsCommerce: select distinct
I have the following query I am trying to optimize. EXPLAIN select clb.f_name, clb.l_name,
I am trying some way to optimize following sql statement: exe_sql DELETE FROM tblEvent_type
I'm trying to optimize the following query but I don't know what to do.
I'm having trouble trying to optimize the following query for sql server 2005. Does
Problem: I am trying to optimize the following into one query. Desired Result: If
I have to perform the following SQL query: select answer_nbr, count(distinct user_nbr) from tpoll_answer
I am trying to optimize this query as good as possible,but still i am
I`m having trouble trying to optimize this query with OVER (PARTITION BY ...) because
We are trying to optimize some of our queries. One query is doing the

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.