indexing

What are the disadvantages of having many indices?

前提是你 提交于 2020-01-10 17:31:13
问题 I recently sped up a complicated query by an order of magnitude by giving SQLite a good index to work with. Results like this make me wonder if I should index a lot of other fields that are commonly used for JOINs or ORDER BY clauses. But I don't want to get overzealous and have it backfire on me: I assume there must be some reasons not to create indices, or every field would be indexed by default. I'm using SQLite in this case, but of course DBMS-agnostic advice is welcome as well. 回答1:

Tuning MySQL for speedy column/index creation during development

早过忘川 提交于 2020-01-10 16:26:10
问题 Assume a MySQL MyISAM table with one gigabyte of data and one gigabyte of indexes. Furthermore, assume that during development columns and indexes will be added and removed from/to the table quite frequently. Due to the size of the database the column/index creation is slow when using the standard non-tuned MySQL settings. Which MySQL server parameters should be tuned in order to minimize the time it takes to add new columns/indexes? 回答1: I believe the key settings you should look at are key

Tuning MySQL for speedy column/index creation during development

此生再无相见时 提交于 2020-01-10 16:24:49
问题 Assume a MySQL MyISAM table with one gigabyte of data and one gigabyte of indexes. Furthermore, assume that during development columns and indexes will be added and removed from/to the table quite frequently. Due to the size of the database the column/index creation is slow when using the standard non-tuned MySQL settings. Which MySQL server parameters should be tuned in order to minimize the time it takes to add new columns/indexes? 回答1: I believe the key settings you should look at are key

How do FULLTEXT INDEXES on multiple columns work?

大兔子大兔子 提交于 2020-01-10 12:58:05
问题 When adding a FULLTEXT INDEX on 3 columns, does that add 1 single index on 3 columns, or does it add 3 separate indexes? I ask this, because at the moment I'm using FULLTEXT like this: ALTER TABLE myTable ADD FULLTEXT all3colsIndex (col1,col2,col3); SELECT * FROM myTable WHERE MATCH (col1, col2, col3) AGAINST ('word'); I have just added a user option to my search interface where the user can remove one of the columns from the search. So am I able to do this without losing the index, where I'm

Large primary key: 1+ billion rows MySQL + InnoDB?

拟墨画扇 提交于 2020-01-10 10:56:29
问题 I was wondering if InnoDB would be the best way to format the table? The table contains one field, primary key, and the table will get 816k rows a day (est.). This will get very large very quick! I'm working on a file storage way (would this be faster)? The table is going to store ID numbers of Twitter Ids that have already been processed? Also, any estimated memory usage on a SELECT min('id') statement? Any other ideas are greatly appreciated! 回答1: The only definitive answer is to try both

Large primary key: 1+ billion rows MySQL + InnoDB?

假装没事ソ 提交于 2020-01-10 10:56:10
问题 I was wondering if InnoDB would be the best way to format the table? The table contains one field, primary key, and the table will get 816k rows a day (est.). This will get very large very quick! I'm working on a file storage way (would this be faster)? The table is going to store ID numbers of Twitter Ids that have already been processed? Also, any estimated memory usage on a SELECT min('id') statement? Any other ideas are greatly appreciated! 回答1: The only definitive answer is to try both

Large primary key: 1+ billion rows MySQL + InnoDB?

夙愿已清 提交于 2020-01-10 10:56:07
问题 I was wondering if InnoDB would be the best way to format the table? The table contains one field, primary key, and the table will get 816k rows a day (est.). This will get very large very quick! I'm working on a file storage way (would this be faster)? The table is going to store ID numbers of Twitter Ids that have already been processed? Also, any estimated memory usage on a SELECT min('id') statement? Any other ideas are greatly appreciated! 回答1: The only definitive answer is to try both

Optimize PostgreSQL read-only tables

一笑奈何 提交于 2020-01-10 10:41:50
问题 I have many read-only tables in a Postgres database. All of these tables can be queried using any combination of columns. What can I do to optimize queries? Is it a good idea to add indexes to all columns to all tables? 回答1: Columns that are used for filtering or joining (or, to a lesser degree, sorting ) are of interest for indexing. Columns that are just selected are barely relevant! For the following query only indexes on a and e may be useful: SELECT a,b,c,d FROM tbl_a WHERE a = $some

pandas - change df.index from float64 to unicode or string

孤人 提交于 2020-01-10 06:52:09
问题 I want to change a dataframes' index (rows) from float64 to string or unicode. I thought this would work but apparently not: #check type type(df.index) 'pandas.core.index.Float64Index' #change type to unicode if not isinstance(df.index, unicode): df.index = df.index.astype(unicode) error message: TypeError: Setting <class 'pandas.core.index.Float64Index'> dtype to anything other than float64 or object is not supported 回答1: You can do it that way: # for Python 2 df.index = df.index.map(unicode

Why postgres is not using the index in my query

喜你入骨 提交于 2020-01-10 06:07:32
问题 I have 2 tables as follow: tb_st: Columns: st_id | integer st | character varying(80) type | integer Indexes: PRIMARY KEY (st_id) UNIQUE INDEX (st, type) INDEX (st) tb_pd: Column st_id | integer bot_id | integer Indexes: PRIMARY KEY (st_id, bot_id) INDEX (bot_id) Foreign-key constraints: FOREIGN KEY (st_id) REFERENCES tb_st(st_id) When i explain the query: select p.bot_id from tb_pd p inner join tb_st s on p.st_id = s.st_id where s.st = 'abc' and s.type = 1 postgres gives me this: Nested Loop