indexing

Which databases can create function-based indexes?

天大地大妈咪最大 提交于 2019-12-24 00:33:32
问题 I know, that this type of indexes exist in Oracle. Old versions on MySQL can not create function-based indexes (thanks, google). And new versions? How about PostgreSQL, SQL Server etc? 回答1: I don't know inner details of oracle's, but postgres can create index on expression, which can be a function, from : An index field can be an expression computed from the values of one or more columns of the table row. This feature can be used to obtain fast access to data based on some transformation of

ArangoDB: performance index in array element

折月煮酒 提交于 2019-12-24 00:25:36
问题 I have a Collection in ArangoDB populated with element like this: { "id": "XXXXXXXX", "relation": [ { "AAAAA": "AAAAA", }, { "BBBB": "BBBBBB", "field": { "v1": 0, "v2": 0, "v3": 0 } }, { "CCCC": "CCCC", "field": { "v1": 0, "v2": 1, "v3": 2 } }, ] } I want to return only elements that have field.v1 > 0 (or a combination of v values). I've tried to write an AQL query like this one, but it doesn't use indexes and it is so slow with 200000+ elements. FOR a in X FILTER LENGTH(a.relation) > 0 LET

How can I get a COUNT(col) … GROUP BY to use an index?

喜欢而已 提交于 2019-12-24 00:08:54
问题 I've got a table (col1, col2, ...) with an index on (col1, col2, ...). The table has got millions of rows in it, and I want to run a query: SELECT col1, COUNT(col2) WHERE col1 NOT IN (<couple of exclusions>) GROUP BY col1 Unfortunately, this is resulting in a full table scan of the table, which takes upwards of a minute. Is there any way of getting oracle to use the index on the columns to return the results much faster? EDIT: more specifically, I'm running the following query: SELECT owner,

Image blending with mask

主宰稳场 提交于 2019-12-24 00:08:23
问题 I'm trying to combine the two images based on the information from the mask. I'm using the color information from the background image if the mask is 0 and color information from foreground image if the mask is 1. Because the mask and both Images are of the same size, I would like to use logical indexing of matrices to achieve this. My attempt: mask = imread('mask.png'); foreground = imread('fg.jpg'); background = imread('bg.jpg'); [r,c,~]=size(mask); A = zeros(size(mask)); for i=1:r for j=1

Create an index on a MySQL column based on the length its contents?

我的未来我决定 提交于 2019-12-23 23:13:04
问题 How do I create an index on a column in MySQL v 5.0 (myisam db engine) based upon the length of its value its a TEXT data type up to 7000 characters, do I have to add another column with the length of the first column? 回答1: Yes, as MySQL doesn't support function-based indexes (like ADD INDEX myIndex(LENGTH(text))) , you'll need a new int column and define a trigger to auto-update it after inserts and updates. 回答2: Sounds like a good approach to me (sorry don't know mysql, but in oracle you

Pandas: extracting multiple rows from DataFrame with list of DatetimeIndices

五迷三道 提交于 2019-12-23 22:07:24
问题 I have a pandas Dataframe with the following index with seconds frequency: DatetimeIndex(['2015-12-28 05:20:05', '2015-12-28 05:20:06', '2015-12-28 05:20:07', '2015-12-28 05:20:08', ... '2015-12-28 21:19:55', '2015-12-28 21:19:56', '2015-12-28 21:19:57', '2015-12-28 21:19:58'] I want to extract multiple rows at once, given a list of datetime strings. I tried: df.loc[['2015-12-28 08:32:39', '2015-12-28 08:32:48']] But I get the following error: KeyError: "None of [['2015-12-28 08:32:39', '2015

Aggregate framework can't use indexes

余生颓废 提交于 2019-12-23 21:57:13
问题 I run this command: db.ads_view.aggregate({$group: {_id : "$campaign", "action" : {$sum: 1} }}); ads_view : 500 000 documents. this queries take 1.8s . this is its profile : https://gist.github.com/afecec63a994f8f7fd8a indexed : db.ads_view.ensureIndex({campaign: 1}); But mongodb don't use index. Anyone know if can aggregate framework use indexes, how to index this query. 回答1: The $group operator is not one of the ones that will use an index currently. The list of operators that do (as of 2.2

Finding the index of the element with class in native Javascript

怎甘沉沦 提交于 2019-12-23 21:11:11
问题 Is there a way to get the index of class name (I.e. the third element with the class "className" would be 3 without using jQ? I don't know jQ, and I don't have time to learn it right now, and I don't want to include code into my code that I don't understand at least some. Thanks. BTW, I've used jQ instead of spelling it out so those results can be filtered out in Google should somebody have the same question. If I spelled it out, and somebody used the NOT operator in Google, this one would

MySql refuses to use index

余生颓废 提交于 2019-12-23 20:57:56
问题 I'm new to query optimizations so I accept I don't understand everything yet but I do not understand why even this simple query isn't optimized as expected. My table: +------------------+-----------+------+-----+-------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------+-----------+------+-----+-------------------+----------------+ | tasktransitionid | int(11) | NO | PRI | NULL | auto_increment | | taskid | int(11) | NO | MUL | NULL | | |

searching on array items on a DynamoDB table

不羁岁月 提交于 2019-12-23 20:01:03
问题 I need to understand how one can search attributes of a DynamoDB that is part of an array. So, in denormalising a table, say a person that has many email addresses. I would create an array into the person table to store email addresses. Now, as the email address is not part of the sort key, and if I need to perform a search on an email address to find the person record. I need to index the email attribute. Can I create an index on the email address, which is 1-many relationship with a person