Giter Site home page Giter Site logo

Not Useful for Large Tables about dbglass HOT 5 CLOSED

pkkid avatar pkkid commented on September 27, 2024 1
Not Useful for Large Tables

from dbglass.

Comments (5)

VladimirPal avatar VladimirPal commented on September 27, 2024

@mjs7231 Honestly we didn't test it on large tables. We'll do it.

from dbglass.

emrul avatar emrul commented on September 27, 2024

You can try:
SELECT reltuples AS approximate_row_count FROM pg_class WHERE relname = 'tbl';
from https://wiki.postgresql.org/wiki/Count_estimate

This is much faster than SELECT COUNT(*) on large tables and on tables that have a lot of dead rows.

from dbglass.

VladimirPal avatar VladimirPal commented on September 27, 2024

https://github.com/web-pal/DBGlass/blob/master/app/actions/tables.js#L62
Here we getting list of tables, using 3 queries. We have to try to get all needed information using one query.

SELECT rel.relname, rel.relkind, rel.reltuples, coalesce(rel.relpages,0)
+ coalesce(toast.relpages,0) AS num_total_pages, SUM(ind.relpages) AS index_pages,
pg_roles.rolname AS owner FROM pg_class rel left join pg_class toast
on (toast.oid = rel.reltoastrelid) left join pg_index on (indrelid=rel.oid)
left join pg_class ind on (ind.oid = indexrelid) join pg_namespace
on (rel.relnamespace =pg_namespace.oid ) left join pg_roles
on ( rel.relowner = pg_roles.oid ) WHERE rel.relkind IN ('r','v','m','f')
AND nspname = 'public'GROUP BY rel.relname, rel.relkind, rel.reltuples,
coalesce(rel.relpages,0) + coalesce(toast.relpages,0), pg_roles.rolname

Some kind of this.
Using this query we also get very quickly approx count of rows on each table and if we have extremely large table then do not use COUT query.

from dbglass.

VladimirPal avatar VladimirPal commented on September 27, 2024

@mjs7231 Can you give us more details, how many rows you had on stucked table? Can you provide us schema of this table? I tested dbglass on 10millions rows and it worked pretty fast.
Want to fix issue with large tables.

from dbglass.

VladimirPal avatar VladimirPal commented on September 27, 2024

#46

from dbglass.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.