简体   繁体   English

列索引和DELETE查询性能

[英]Column Indexing and DELETE query performance

I have a table with few Columns like ID (PK), Name, created_time etc. and periodically I DELETE rows from this table by using this simple DELETE query. 我有一个表,其中包含ID(PK),名称,created_time等几列,并且使用此简单的DELETE查询定期从该表中删除行。

DELETE FROM my_table WHERE created_time < 'some time';

Just want to know what will be the performance impact on INSERT , SELECT and DELETE if I make or not make an INDEX on created_time . 只想知道如果我在created_time上创建或不创建INDEX ,会对INSERTSELECTDELETE的性能产生什么影响。

This table may have millions of rows and one DELETE query may delete rows in hundred thousands in one go. 该表可能具有数百万行,并且一个DELETE查询可能会一次删除数十万行。

Database : Oracle, JavaDB, DB2, SQL Server 数据库:Oracle,JavaDB,DB2,SQL Server

If you make an INDEX on created_time. 如果您在created_time上输入INDEX。 1. Insert it will slow because it need to check column created_time is one time only(like a key). 1.插入它会很慢,因为它需要检查一列created_time仅是一次(如键)。 2. SELECT and DELETE will quick if your condition where WHERE created_time = 'some time' It's mean if it find the first row of condition it will stop. 2.如果您的条件WHERE created_time ='some time',则SELECT和DELETE将很快执行。这意味着如果找到条件的第一行,它将停止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM