indexing

Grails multi column indexes

不问归期 提交于 2019-12-20 18:01:23
问题 Can someone explain how to define multi column indexes in Grails? The documentation is at best sparse. This for example does not seem to work at all: http://grails.org/GORM+Index+definitions I've had some luck with this, but the results seems random at best. Definitions that works in one domain class does not when applied to another (with different names of course). http://www.grails.org/doc/1.1/guide/single.html#5.5.2.6%20Database%20Indices Some working examples and explanations would be

Efficient search of sorted numerical values

ⅰ亾dé卋堺 提交于 2019-12-20 14:43:28
问题 I have an int[] array that contains values with the following properties: They are sorted They are unique (no duplicates) They are in a known range [0..MAX) MAX is typically quite a lot larger than the length of the array (say 10-100x) Sometimes the numbers are evenly distributed across the range, but at other times there are quite long sequences of consecutive numbers. I estimate it is about 50/50 between the two cases. Given this list, I want to efficiently find the index of a specific

Efficient search of sorted numerical values

匆匆过客 提交于 2019-12-20 14:43:02
问题 I have an int[] array that contains values with the following properties: They are sorted They are unique (no duplicates) They are in a known range [0..MAX) MAX is typically quite a lot larger than the length of the array (say 10-100x) Sometimes the numbers are evenly distributed across the range, but at other times there are quite long sequences of consecutive numbers. I estimate it is about 50/50 between the two cases. Given this list, I want to efficiently find the index of a specific

Why isn't index used for this query?

╄→гoц情女王★ 提交于 2019-12-20 12:53:03
问题 I had a query where an index was not used when I thought it could be, so I reproduced it out of curiosity: Create a test_table with 1.000.000 rows (10 distinct values in col , 500 bytes of data in some_data ). CREATE TABLE test_table AS ( SELECT MOD(ROWNUM,10) col, LPAD('x', 500, 'x') some_data FROM dual CONNECT BY ROWNUM <= 1000000 ); Create an index and gather table stats: CREATE INDEX test_index ON test_table ( col ); EXEC dbms_stats.gather_table_stats( 'MY_SCHEMA', 'TEST_TABLE' ); Try to

Is there any logical reason of having different tablespace for indexes?

谁都会走 提交于 2019-12-20 10:51:32
问题 Hi Can some let me know why we created different table space for Index and data. 回答1: It is a widespread belief that keeping indexes and tables in separate tablespaces improves performance. This is now considered a myth by many respectable experts (see this Ask Tom thread - search for "myth"), but is still a common practice because old habits die hard! Third party edit Extract from asktom: "Index Tablespace" from 2001 for Oracle version 8.1.6 the question Is it still a good idea to keep

Is there any logical reason of having different tablespace for indexes?

霸气de小男生 提交于 2019-12-20 10:51:28
问题 Hi Can some let me know why we created different table space for Index and data. 回答1: It is a widespread belief that keeping indexes and tables in separate tablespaces improves performance. This is now considered a myth by many respectable experts (see this Ask Tom thread - search for "myth"), but is still a common practice because old habits die hard! Third party edit Extract from asktom: "Index Tablespace" from 2001 for Oracle version 8.1.6 the question Is it still a good idea to keep

Determining if MySQL table index exists before creating

不羁的心 提交于 2019-12-20 10:42:40
问题 Our system's automated database migration process involves running .sql scripts containing new table definitions and their accompanying indexes. I require the ability to create these tables and indexes only if they don't already exist. Tables are taken care of by using IF NOT EXISTS but no such syntax exists when creating indexes. I've tried to write a stored procedure, shown below, but this fails presumably as you can't select from a show statement. DELIMITER $$ DROP PROCEDURE IF EXISTS csi

Best SQL indexes for join table

血红的双手。 提交于 2019-12-20 10:29:31
问题 With performance improvements in mind, I was wondering if and which indexes are helpful on a join table (specifically used in a Rails 3 has_and_belongs_to_many context). Model and Table Setup My models are Foo and Bar and per rails convention, I have a join table called bars_foos . There is no primary key or timestamps making the old fields in this table bar_id:integer and foo_id:integer . I'm interested in knowing which of the following indexes is best and is without duplication: A compound

Why isn't SQL Server using my index?

强颜欢笑 提交于 2019-12-20 10:24:23
问题 In our database we have this table with 200.000 rows CREATE TABLE dbo.UserTask ( UserTask_ID int NOT NULL IDENTITY (1, 1), UserTask_SequenceNumber int NOT NULL DEFAULT 0, UserTask_IdEntitat uniqueidentifier NOT NULL, UserTask_Subject varchar(100) NOT NULL, UserTask_Description varchar(500) NOT NULL, ..... ..... CONSTRAINT [PK_UserTask] PRIMARY KEY CLUSTERED ( [UserTask_ID] ASC ) ON [PRIMARY] ) ON [PRIMARY] I have created an index on UserTask_IdEntitat column with CREATE NONCLUSTERED INDEX IX

SQL Server STATISTICS

天涯浪子 提交于 2019-12-20 09:56:21
问题 So for this one project, we have a bunch of queries that are executed on a regular basis (every minute or so. I used the "Analyze Query in Database Engine " to check on them. They are pretty simple: select * from tablex where processed='0' There is an index on processed, and each query should return <1000 rows on a table with 1MM records. The Analyzer recommended creating some STATISTICS on this.... So my question is: What are those statistics ? do they really help performance ? how costly