MySQL index design with table partitioning
NickName:Amila Ask DateTime:2011-06-12T01:54:33

MySQL index design with table partitioning

I have 2 MySQL tables with the following schemas for a web site that's kinda like a magazine.

Article (articleId int auto increment ,
         title varchar(100),
         titleHash guid -- a hash of the title
         articleText varchar(4000)
         userId int)

User (userId int autoincrement
      userName varchar(30)
      email etc...)

The most important query is;

select title,articleText,userName,email 
from Article inner join user
on article.userId = user.UserId
where titleHash = <some hash>

I am thinking of using the articleId and titleHash columns together as a clustered primary y for the Article table. And userId and userName as a primary key for the user table. As the searches will be based on titlehash and userName columns.

Also titlehash and userName are unqiue by design and will not change normally.

The articleId and userid columns are not business keys and are not visible to the application, so they'll only be used for joins.

I'm going to use mysql table partitioning on the titlehash column so the selects will be faster as the db will be able to use partition elimination based on that column.

I'm using innoDB as the storage engine;

So here are my questions;

  1. Do I need to create another index on the titlehash column as the primary key (articleId,titlehash) is not good for the searches on the titlehash column as it is the second column on the primary key ?

  2. What are the problems with this design ?

I need the selects to be very fast and expects the tables to have millions of rows and please note that the int Id columns are not visible to the business layer and can never be used to find a record

I'm from a sql server background and going to use mysql as using the partitioning on sql server will cost me a fortune as it is only available in the Enterprise edition.

So DB gurus, please help me; Many thanks.

Copyright Notice:Content Author:「Amila」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/6317593/mysql-index-design-with-table-partitioning

More about “MySQL index design with table partitioning” related questions

MySQL index design with table partitioning

I have 2 MySQL tables with the following schemas for a web site that's kinda like a magazine. Article (articleId int auto increment , title varchar(100), titleHash guid -- a hash...

Show Detail

Mysql Partitioning effect on Index

I have multiple big tables for business data with smallest one having 38million rows(24G data, 26G index size). I have indexes setup to speed up the lookups and buffer pool set to 80% of total RAM(...

Show Detail

MySQL partitioning by table rows

I create a table as below CREATE TABLE `Archive_MasterLog` ( `LogID` INT(10) NOT NULL AUTO_INCREMENT, `LogDate` DATETIME NULL, `AssessorName` VARCHAR(255) NULL, `TblName` VARCHAR(100) NULL...

Show Detail

MySQL table partitioning on timestamp

I have partitioned a table (because of an out of memory error - table got too big). I have partitioned it on a timestamp column as shown below: CREATE TABLE test ( fname VARCHAR(50) NOT NULL,...

Show Detail

MySQL partitioning with ActiveRecord

I want to take advantage of the new partitioning in MySQL 5.1 but using a standard ActiveRecord model. The problem I have encountered is that to use the partitioning the primary key on the table m...

Show Detail

Partitioning a mySQL table

I am considering partitioning a mySQL table that has the potential to grow very big. The table as it stands goes like this DROP TABLE IF EXISTS `uidlist`; CREATE TABLE IF NOT EXISTS `uidlist` ( ...

Show Detail

Dynamic MySQL partitioning based on UnixTime

My DB design includes multiple MYISAM tables with measurements collected online, Each row record contains auto-incremented id, some data and an integer representing unixtime. I am designing an ag...

Show Detail

SQL table Partitioning by Year with ColumnStore index implemented on the table

SQL Server 2014 I have developed a SSIS package to load data to one DW database. Below is my understanding - Create Main table with Clustered index + ColumnStore index + PARTITIONING TABL...

Show Detail

Determining partitioning key in range based partitioning of a MySQL Table

I've been researching for a while regarding database partitioning in MySQL. Since I have one ever-growing table in my DB, I thought of using partitioning as an effective tool to optimize it. I'm only

Show Detail

Is this MySql table a good candidate for partitioning?

I have a table with ~1.9 million rows and growing consistently. I run some fairly complicated queries against this data. The active data is generally clustered toward the end of the table -- that...

Show Detail