Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make table partitions?

I am not very familiar with databases, and so I do not know how to partition a table using SQLAlchemy.

Your help would be greatly appreciated.

like image 800
Ryan Avatar asked Nov 23 '25 21:11

Ryan


2 Answers

There are two kinds of partitioning: Vertical Partitioning and Horizontal Partitioning.

From the docs:

Vertical Partitioning

Vertical partitioning places different kinds of objects, or different tables, across multiple databases:

engine1 = create_engine('postgres://db1')
engine2 = create_engine('postgres://db2')
Session = sessionmaker(twophase=True)
# bind User operations to engine 1, Account operations to engine 2
Session.configure(binds={User:engine1, Account:engine2})
session = Session()

Horizontal Partitioning

Horizontal partitioning partitions the rows of a single table (or a set of tables) across multiple databases.

See the “sharding” example in attribute_shard.py

Just ask if you need more information on those, preferably providing more information about what you want to do.

like image 176
nosklo Avatar answered Nov 25 '25 09:11

nosklo


It's quite an advanced subject for somebody not familiar with databases, but try Essential SQLAlchemy (you can read the key parts on Google Book Search -- p 122 to 124; the example on p. 125-126 is not freely readable online, so you'd have to purchase the book or read it on commercial services such as O'Reilly's Safari -- maybe on a free trial -- if you want to read the example).

Perhaps you can get better answers if you mention whether you're talking about vertical or horizontal partitioning, why you need partitioning, and what underlying database engines you are considering for the purpose.

like image 41
Alex Martelli Avatar answered Nov 25 '25 09:11

Alex Martelli