Skip to main content
Tweeted twitter.com/StackDBAs/status/1266927503907618823
Became Hot Network Question
format
Source Link
Erwin Brandstetter
  • 186.5k
  • 28
  • 465
  • 639

I have a table with about 10mln rows in it with a primary key and an index defined on it:

 create table test.test_table(   date_info date not null,   string_data varchar(64) not null,   data bigint   primary key(date_info, string_data));   create index test_table_idx   on test.test_table(string_data); 

I have a query that makes the use of the test_table_idxtest_table_idx:

select distinct date_info from test.test_table where string_data = 'some_val'; 

The issue is that first time around it could take up to 20 seconds to run the query and < 2 seconds on any subsequent runs.

Is there a way to pull load the entire index into memory rather then have DB load information on first access?

I have a table with about 10mln rows in it with a primary key and an index defined on it:

 create table test.test_table(   date_info date not null,   string_data varchar(64) not null,   data bigint   primary key(date_info, string_data));   create index test_table_idx   on test.test_table(string_data); 

I have a query that makes the use of the test_table_idx:

select distinct date_info from test.test_table where string_data = 'some_val'; 

The issue is that first time around it could take up to 20 seconds to run the query and < 2 seconds on any subsequent runs.

Is there a way to pull load the entire index into memory rather then have DB load information on first access?

I have a table with about 10mln rows in it with a primary key and an index defined on it:

create table test.test_table( date_info date not null, string_data varchar(64) not null, data bigint primary key(date_info, string_data)); create index test_table_idx on test.test_table(string_data); 

I have a query that makes the use of the test_table_idx:

select distinct date_info from test.test_table where string_data = 'some_val'; 

The issue is that first time around it could take up to 20 seconds to run the query and < 2 seconds on any subsequent runs.

Is there a way to pull load the entire index into memory rather then have DB load information on first access?

Source Link
Karlson
  • 191
  • 2
  • 8

Pre Caching Index on a large table in PostgrSQL

I have a table with about 10mln rows in it with a primary key and an index defined on it:

 create table test.test_table( date_info date not null, string_data varchar(64) not null, data bigint primary key(date_info, string_data)); create index test_table_idx on test.test_table(string_data); 

I have a query that makes the use of the test_table_idx:

select distinct date_info from test.test_table where string_data = 'some_val'; 

The issue is that first time around it could take up to 20 seconds to run the query and < 2 seconds on any subsequent runs.

Is there a way to pull load the entire index into memory rather then have DB load information on first access?