Skip to main content

Memorable SQL statistics

I was casually reading the PostgreSQL FAQ, looking at neater ways of extracting DATABASE & TABLE definitions than multiply JOINed SELECTs across pg_* system tables, when I ran across this little snippet:
To uniquely number rows in user tables, it is best to use SERIAL rather than OIDs because SERIAL sequences are unique only within a single table. and are therefore less likely to overflow. SERIAL8 is available for storing eight-byte sequence values.
OK, so here I am hypothetically wanting to stick more than 4 billion objects into my databases.

Firstly, let’s think about such a table, with lines of text packed into it, an INTEGER (well, SERIAL) & a VARCHAR for each row — averaging, say, 60 characters per row. That’s 4 billion times 69 bytes, or roughly 280GB in one TABLE. A ‘SELECT * FROM’ would take a fair while.

Well... that’s OK, I can buy a disk that large, & there’s those SERIAL8s to play with, to give me 16 billion billion items in one TABLE.

Or to put it another way, an example TABLE as above resting in a mere million terabytes or so. So if we add 1,000 records a second to this TABLE, we’re looking at many, many lifetimes (at a mere 86 million records a week, 31 billion a year, so roughly 8 million years) just waiting for it to load.

Hmmm. “Sorry, do you have disks with a 16 megayear MTBF?” Ducking, running very fast.

Good thing PostgreSQL limits itself to 32TB, no? (-:

...er, & that I won't be hitting the 400GB-a-row limit, either. The concept of two rows consuming the largest hard disk I can buy is a bit staggering. Backups will not be fun.

I should mention that MySQL looks a lot easier to get these basic stats out of; SHOW DATABASES, SHOW [FULL] TABLES, SHOW INDEX FROM etc. Must try that next. (-:

Comments

Popular posts from this blog

every-application-is-part-of-a-toolkit at work

I have a LibreOffice Impress slideshow that I wish to turn into a narrated video. 1. export the slideshow as PNG images (if that is partially broken — as at now — at higher resolutions, Export Directly as PDF then use ‘pdftoppm’ (from the poppler-utils package) to do the same). 2. write a small C program (63 lines including comments) to display those images one at a time, writing a config file entry for Imagination (default transition: ‘cross fade’) based on when the image-viewer application (‘display,’ from the GraphicsMagick suite) is closed on each one; run that, read each image aloud, then close each image in turn. 3. run ‘Imagination’ over the config file to produce a silent MP4 video with the correct timings. 4. run ‘Audacity’ to record speech while using ‘SMPlayer’ to display the silent video, then export that recording as a WAV file. 4a. optionally, use ‘TiMIDIty’ to convert a non-copyright-encumbered MIDI tune to WAV, then import that and blend it with the speech (as a quiet b

new life for an old (FTX) PSU, improved life for one human

the LEDs on this 5m strip happen to emit light centred on a red that does unexpectedly helpful things to (and surprisingly deeply within) a human routinely exposed to it. it has been soldered to a Molex connector, plugged into a TFX power supply from a (retired: the MoBo is cactus) Small Form Factor PC, the assorted PSU connectors (and loose end from the strip) have been taped over. the LED strip cost $10.24 including postage, the rest cost $0, the PSU is running at 12½% of capacity, consumes less power than a laptop plug-pack despite running a fan. trial runs begin today.

boundaries

pushing the actual boundaries of the physical (not extremes, the boundaries themselves) can often remove barriers not otherwise perceived. one can then often resolve an issue itself, rather than merely stonewalling at the physical consequences of the issue.