Re: disable index while doing insert into
- From: sai <go2sai@xxxxxxxxx>
- Date: 17 May 2007 15:05:56 -0700
On May 17, 4:02 pm, Klaus Riemer <k...@xxxxxxxxxxxxxxxxxxx> wrote:
sai schrieb:> Hi All,
I have a query that does an "insert into... select from", both the
source and target table have multiple indexes, it is taking too long
to execute this query but when i've deleted the indexes on target
table, insert took very little time.
Is there a way to disable indexes before executing a query and enable
them back after executing query ?
This is a price you have to pay on any database not just Sybase.
Once you insert in a database with indexes then the index key fields
must be adjusted as well. B-trees eventually rebalanced and so on.
I assume you have a clustered index on your table. This is particular an
issue when you do mass inserts and the index will maintain a sort
order to this index. Then the effect you describe might become more
visible compared to other kind of index.
(Lots of I/O - operations)
If you could disable an index during a set of insert opeartions or mass
insert such as bulk copy (bcp) then your index is either incorrect or
the housekeeper must do it. So or so you would have either slow insert,
bad query performance and so on.
If your business process permits this procedure
I suggest to drop before insert and recreate indexes after insert /
bulkcopy. This is probably faster than slow insert e.g. on bulk insert.
Again as mentioned before: Beware of clustered indexes when doing
inserts with not corresponding sort - order. The server will then resort
the table on each insert operation. Occasional page split .... That is a
lot of work when inserting...
You have a lot of indexes - do you do reporting and analytics on your
database ? In this case you should really consider Sybase IQ - That one
is designed for this kind of job!
--Klaus Riemer, Greven - DE
--klausATroehlergenriemer!REMOVESPAMPROTECTORBEFOREMAIL!.de
--
Thanks a lot for your suggestions,
i was thinking about using update statistics after enabling indexes
( if at all there is a way to disable/enable indexes..)..but i guess
it turns out to be one and the same..forgive my ignorance
.
- Follow-Ups:
- Re: disable index while doing insert into
- From: Klaus Riemer
- Re: disable index while doing insert into
- References:
- disable index while doing insert into
- From: sai
- Re: disable index while doing insert into
- From: Klaus Riemer
- disable index while doing insert into
- Prev by Date: problem with BCP: skip the first data row
- Next by Date: generate index ddl from database
- Previous by thread: Re: disable index while doing insert into
- Next by thread: Re: disable index while doing insert into
- Index(es):
Relevant Pages
|