indexing

how to index on a column for is not null query in oracle?

本秂侑毒 提交于 2020-01-07 02:26:07
问题 I have a table with a lot of column and my query is like this select * from ( select my_table_id from my_table where start_time_local>=? and type_pk<>? and rule_pk=? and this_.name is not null order by start_time_gmt desc ) where rownum <= ? If I create an index on (start_time_local, type_pk, rule_pk, name) it will be inefficient because name is a varchar(1024). Is there a better way to index on something like: (start_time_local, type_pk, rule_pk, isNotNull(name)) Thanks, 回答1: Generally, the

how to index on a column for is not null query in oracle?

爷,独闯天下 提交于 2020-01-07 02:26:05
问题 I have a table with a lot of column and my query is like this select * from ( select my_table_id from my_table where start_time_local>=? and type_pk<>? and rule_pk=? and this_.name is not null order by start_time_gmt desc ) where rownum <= ? If I create an index on (start_time_local, type_pk, rule_pk, name) it will be inefficient because name is a varchar(1024). Is there a better way to index on something like: (start_time_local, type_pk, rule_pk, isNotNull(name)) Thanks, 回答1: Generally, the

What kind of index would be efficient when there is IN clause?

…衆ロ難τιáo~ 提交于 2020-01-07 02:22:21
问题 Here is my query: DELETE FROM events WHERE type = 4 AND author_id IN (?, ?) AND post_id IN (?, ?) And here is all my current indexes: (id) -- PK (author_id, seen) (author_id, date_time) (type, other_id, author_id) (comment_id, type, author_id) Well, Should I add any new index for query above? 回答1: I would guess an index on type would probably be the only useful one; because A IN (B, C, D) translates to A = B OR A = C OR A = D , and MySQL seems to ignore indices once it encounters an OR .

Haystack indexing related model issue

血红的双手。 提交于 2020-01-07 00:07:51
问题 I want to prepare an index for two models, so I can search text from both models. Below is my code. When I run "python manage.py rebuild_index" I get the error "raise self.related.model.DoesNotExist" for the index line "return obj.mainparts.parts". models.py class Main(models.Model): ....#various fields class Parts(models.Model): main = models.OneToOneField(Main, primary_key=True, related_name='mainparts') parts = models.TextField(blank=True) search_indexes.py class MainIndex(indexes

Haystack indexing related model issue

无人久伴 提交于 2020-01-07 00:05:22
问题 I want to prepare an index for two models, so I can search text from both models. Below is my code. When I run "python manage.py rebuild_index" I get the error "raise self.related.model.DoesNotExist" for the index line "return obj.mainparts.parts". models.py class Main(models.Model): ....#various fields class Parts(models.Model): main = models.OneToOneField(Main, primary_key=True, related_name='mainparts') parts = models.TextField(blank=True) search_indexes.py class MainIndex(indexes

How to arrange table data differently by using if, match, and index?

扶醉桌前 提交于 2020-01-06 21:05:52
问题 As shown in the attached image, I need to convert A2:D10 to the format of A12:E17. The 4 tables from F1 to AB12 are my experiments using if, match, and index. Same formula gets different results and it seems to be dependent on the row position of the tables. In My previous question, I was trying to pinpoint the problem to the if function. What am I doing wrong here? Thanks, Lu enter image description here 回答1: Again, as I said in your last question: The formula has not been array entered.

How to arrange table data differently by using if, match, and index?

℡╲_俬逩灬. 提交于 2020-01-06 21:05:48
问题 As shown in the attached image, I need to convert A2:D10 to the format of A12:E17. The 4 tables from F1 to AB12 are my experiments using if, match, and index. Same formula gets different results and it seems to be dependent on the row position of the tables. In My previous question, I was trying to pinpoint the problem to the if function. What am I doing wrong here? Thanks, Lu enter image description here 回答1: Again, as I said in your last question: The formula has not been array entered.

Calculate Scrabble word scores for double letters and double words MATLAB

我的未来我决定 提交于 2020-01-06 20:36:22
问题 My goal here is to create code that takes the letters in a string and gives out a score like in Scrabble. It has to account for double words scores (dictated by a !) and double letter score (dictated by a #). Example: If you input was 'Hel#lo!', then the first 'l' was played on a double letter score space, and the final 'o' was played on a double word score space. The output score would be 18. Thanks to help from rayryeng I finally got it to read off the score value if there were no double

Optimizing a very huge mysql table (query or mysql)

微笑、不失礼 提交于 2020-01-06 12:50:24
问题 I have a mysql DB with 50 GB data and 200M record in a table. I am running following query and it takes 350 second to complete: SELECT x_date, count(*) as totl FROM `rec_ex_15` WHERE x_date > '2014-12-01' and typx = '2' group by x_date order by x_date desc x_date and typx are indexed. Here is the explain: id select_type table type possible_keys key key_len ref rows 1 SIMPLE rec_ex_15 range typx,x_date x_date 3 NULL 15896931 Using where Are there any way to get the result faster? 回答1: As noted

How to know the indices of values in collection [closed]

孤街浪徒 提交于 2020-01-06 12:39:54
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . Referring to this question: How to subtract dates from each other In Groovy, I've got a script that spits out the 5 largest values from a text file collection. How can I know what the indices of those values are? 回答1: If you have a list of things ie: def list = [ 'c', 'a', 'b' ] One way of knowing