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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:59:40+00:00 2026-06-12T02:59:40+00:00

I have a table (let’s called it table_a). It got around 15 million rows.

  • 0

I have a table (let’s called it table_a). It got around 15 million rows. It’s a simple table that have a primary key.

Recently I created a backup table(let’s called it table_a_bkp) and moved 12 million rows from table_a.
I used simple SQL (delete/insert) to perform the task.
Both tables have same structure and use same tablespace.

Query speed of table_a doesn’t improved even total data rows reduced to 2+ million.
In fact table_a_bkp(12m rows) even have faster query speed than table_a(2m rows).

Checked with pg_stat_all_tables two tables both seems auto vacuum & analyze after deletion performed.

I expected table_a query speed should be improved as it got much less data now…

DB Version : PostgreSQL 9.1 hosted on Linux

EXPLAIN (backup table is faster than 1st table even rows is much larger) :

EXPLAIN (ANALYZE TRUE, COSTS TRUE, BUFFERS TRUE) select count(*) from txngeneral
"Aggregate  (cost=742732.94..742732.95 rows=1 width=0) (actual time=73232.598..73232.599 rows=1 loops=1)"
"  Buffers: shared hit=8910 read=701646"
"  ->  Seq Scan on txngeneral  (cost=0.00..736297.55 rows=2574155 width=0) (actual time=17.614..72763.873 rows=2572550 loops=1)"
"        Buffers: shared hit=8910 read=701646"
"Total runtime: 73232.647 ms"



EXPLAIN (ANALYZE TRUE, COSTS TRUE, BUFFERS TRUE) select count(*) from txngeneral_bkp
"Aggregate  (cost=723840.13..723840.14 rows=1 width=0) (actual time=57134.270..57134.270 rows=1 loops=1)"
"  Buffers: shared hit=96 read=569895"
"  ->  Seq Scan on txngeneral_bkp  (cost=0.00..693070.30 rows=12307930 width=0) (actual time=5.436..54889.543 rows=12339180 loops=1)"
"        Buffers: shared hit=96 read=569895"
"Total runtime: 57134.321 ms"

Resolved: VACUUM FULL did speed up table scan.

  • 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-12T02:59:42+00:00Added an answer on June 12, 2026 at 2:59 am

    You should VACUUM ANALYZE your original table. (Probably a full VACUUM will be needed.) Since the new table was created and populated all at once, they form more or less contiguous ‘blocks’, while the tuples of original table are spread all over the disk.

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

Sidebar

Related Questions

Let's say I have table TabA with columns: col1 - primary key (but not
Let's say I have a table called messages with the columns: id | from_id
Let's say I have a table with 1M rows and I need to add
Let's say I have a table called Users which represents registered users of a
I have a table let say is it called test. I use Ubuntu and
Let's say I have table like this: id: PRIMARY INT price: INT (in dollars)
Simplified situation: I have a table, let's call it header with, say, a primary
Let say that I have table TableA(ColumnCode, ColumnA2, ColumnA3, ColumnA4, ColumnA5). Note: ColumnCode(PrimaryKey)is not
I have table with following structure id int auto increment, primary key uid int
I have a table (let's call it tableA) that looks something like this: id

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.