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 8988315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:59:33+00:00 2026-06-15T21:59:33+00:00

I have table with above 100mln rows. I have to count, and extract rows

  • 0

I have table with above 100mln rows. I have to count, and extract rows as in following query. The query runs verly long. Explain shows that query doesn’t use b-tree index which is created on “created_date” column.
I found on stackoverflow some explanation, that b-trees indicies are useless to filter when table has many rows.

There is an advice to Cluster Index. Should i Cluster table on “created_date” index, if i also use often query, where i ORDER BY id?

What would you advice me to faster queries? Maybe should i read more about sharding?

 explain SELECT count(r.id) FROM results_new r
 WHERE r.searches_id = 4351940 AND (created_date between '2008-01-01'  and '2012-12-13') 


Limit  (cost=1045863.78..1045863.79 rows=1 width=4)
   ->  Aggregate  (cost=1045863.78..1045863.79 rows=1 width=4)
    ->  Index Scan using results_new_searches_id_idx on results_new r  (cost=0.00..1045012.38 rows=340560 width=4)"
          Index Cond: (searches_id = 4351940)"
          Filter: ((created_date >= '2008-01-01 00:00:00'::timestamp without time zone) AND (created_date <= '2012-12-13 00:00:00'::timestamp without time zone))
  • 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-15T21:59:35+00:00Added an answer on June 15, 2026 at 9:59 pm

    From the look of it, the database has decided that a lookup for one searches_id will produce fewer rows to go through than a lookup for the created_date range. (and that combining the result of two index scans with a bitmap isn’t worthwhile…)

    If you need this query often, then consider creating an index on searches_id, created_date and then both conditions should go into the index condition.

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

Sidebar

Related Questions

I have a self-referential table in my database that looks sort of like above.
I have table with around 70 000 rows. There is 6000 rows that i
I have a table that contains the following sample data:- ID Description 1 John
I have a table where it appends rows and that I have 3 rows,
I have table in which I am inserting rows for employee but next time
I have table of data that is sorted as follows: Item | Sample |
I have table with column Percentage varchar(10) Data in that table is Pecentage 2/10
I have table in an MS Access database that looks like this: ID Symbol
I have a table x that's like the one bellow: id | name |
I have a table that looks something like this: CREATE TABLE student_results(id integer, name

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.