sqlite vs postgresql - database size comparision - postgresql

I have a sqlite db file which includes 2 tables and each has over 800k records. the sqlite db file size is 186MB.
I was planned to migrate those records to postgresql database.
In order to made it, I followed these steps:
1) prepared a view to unify these 2 tables in sqlite (they have relation)
2) create a table with one column type jsonb in postgres
3) made a simple program to read from sqlite and then write to postgresql
all 3 steps worked fine... sadly I didn't get what I expected!
postgresql table size is 367MB...
I thought that was going to be much lesser!
How could that be possible the sqlite tables (800k *2 records) consume less disk space than postgresql with one jsonb column and half record?!

Related

Cloudant/Db2 - How to determine if a database table row was read from?

I have two databases - Cloudant and IBM Db2. I have a table in each of these databases that hold static data that is only read from and never updated. These were created a long time ago and I'm not sure if they are used today so I wish to do a clean-up.
I want to determine if these tables or rows from these tables, are still being read from.
Is there a way to record the read timestamp (or at least know if it is simply accessed like a dirty bit) on a row of the table when it is read from?
OR
Record the read timestamp of the entire table (if any record from it is accessed)?
There is SYSCAT.TABLES.LASTUSED system catalog column in Db2 for DML statements on whole table.
There is no way to track each table row read access.

How to take conditional back up of database in postgres?

I am using postgres as database in my production system.
Version: psql (PostgreSQL) 12.9
Os: Ubuntu 18.04
PgAmin 4: version 6.4
Server instance: AWS RDS
My database is growing day by day and now it scales in GBs. i want to take back up of database in local system but the thing is not to take whole back up as production database is so big and i dont need some of the data as they are in GBs.
Example:
If my database has 5 tables,
table A, table B, table C, table D, table E
I want to take back up of schema(structure) of all table but not the data of all table.
Like,
Table name
Schema
Data
Table A
yes
Yes
Table B
yes
No
Table C
yes
No
Table D
yes
No
Table E
yes
Yes
Here,
Schema = yes means include schema of table in back up of database
Schema = No means exclude schema of table in back up of database
Data = yes means include data of table in back up of database
Data = No means exclude data of table in back up of database
How can i take local back up like above mentioned way?
My aim is to ignore data of some table which have more data and scales in GBs.

postgres - move one part of partitioned table to new db as independent table

I have postgresql DB with partitioned table - can somebody help me understood how convert one part of this partitioned table to regular table in new DB?
When i search on google found information about partitioned :/ How proper ask google of operation which I want to perform?

Add new column to existing table CloudSQL Postgres 9.6

When adding a column to an existing table (without specifying a default value), does CloudSQL rewrite the entire table + indexes or does it simply update the metadata, the way Postgres 9.6 does? Asking because I tried adding a column to a large table today (200 million rows) and it took an extremely long time to finish, which makes me think that CloudSQL is rewriting the table/indexes.

Clearing records in HBase table

We are creating a Disaster Recovery System for HBase tables. Because of the restrictions we are not able to use the fancy methods to maintain the replica of the table. We are using Export/Import statements to get the data into HDFS and using that to create tables in the DR Servers.
While Importing the data into HBase table, we are using truncate command to clear the table and load the data fresh into the table. But the truncate statement is taking a long time to delete the rows. Is there are any other effective statements to clear the entire table?
(truncate takes 33 min for ~2500000 records)
disable -> drop -> create table again, maybe ? I don't know if drop takes too long.