Hi,

actually it depends on table type.
Since you said that it will be temp table then I guess it will be MyISAM
table.
In this case it is better to use 2 way:

> 2-nd case: I create table, filling data and then create indexes?

But if you will create InnoDB temp table that (according to Heikki Tuuri)
better to use 1 way:

> 1-st case: I create table and create indexes immediately before
> filling data.

Look at this email from Heikki Tuuri:

************************************
Hi!

You should always create the indexes BEFORE adding the data to an InnoDB
table.

In CREATE INDEX ... ON ..., MySQL rebuilds the whole table. Thus, it will be
much slower to add the indexes afterwards.

Many databases have an optimized index build procedure where adding an index
afterwards is faster, but that is not the case for InnoDB.

DISABLE KEYS has no effect on InnoDB.

It is in the TODO to speed up index creation. Maybe in 2005 it will be
faster to add the indexes afterwards :).

Best regards,

Heikki Tuuri
Innobase Oy
http://www.innodb.com
Foreign keys, transactions, and row level locking for MySQL
InnoDB Hot Backup - a hot backup tool for InnoDB which also backs up MyISAM
tables

Order MySQL technical support from https://order.mysql.com/
************************************

Best regards,
Mikhail.

----- Original Message ----- 
From: "Krasimir_Slaveykov" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 30, 2004 3:14 PM
Subject: SQL and productivity


> Hello ,
>
> I must create a temp table with 5 or more million records.
> I need it for creating some reports, so I need to create indexes too.
> My question is:
> When total time for work will be smaller? :
> 1-st case: I create table and create indexes immediately before
> filling data.
> 2-nd case: I create table, filling data and then create indexes?
>
>
>
>
>
>
> -- 
> Best regards,
> Krasimir_Slaveykov
> mailto: [EMAIL PROTECTED]  [EMAIL PROTECTED]
>
> |-------------------------------------------------|
> |/////  ****   ***** ***** ***  ****  *****   ** /|
> |//// *** *** ***   ***   *** *** ** ***   **** //|
> |/// *** *** ***** ***** *** ***    *****  *** ///|
> |// *** *** ***   ***   *** *** ** ***    *** ////|
> |/   ****  ***   ***   ***  ****  *****  *** /////|
> |--------------- www.office1.bg ------------------|
>
>
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
>
>


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to