indexing

How to call items from an array inside a function

∥☆過路亽.° 提交于 2020-01-17 06:18:13
问题 I have a function "zoom" which takes the following format: zoom( [a,b,c,d....], [a,b,c,d...] ); I also have a for loop which gets me the values that need to go into the zoom array: ABC.getAggregation("V")[0].getItems().forEach( function (item) { var a = item.getPosition().split(";")[0]; var b = item.getPosition().split(";")[1]; ABC.zoom( [...], [...] ); }); How can I add variables a and b into the arrays of function zoom? All variable a's must go into the first array and all variables b must

Google datastore - index a date created field without having a hotspot

一世执手 提交于 2020-01-17 06:11:45
问题 I am using Google Datastore and will need to query it to retrieve some entities. These entities will need to be sorted by newest to oldest. My first thought was to have a date_created property which contains a timestamp. I would then index this field and sort on this field. The problem with this approach is it will cause hotspots in the database (https://cloud.google.com/datastore/docs/best-practices). Do not index properties with monotonically increasing values (such as a NOW() timestamp).

Mongodb 2.4 2dsphere queries very slow (using $geoIntersects)?

和自甴很熟 提交于 2020-01-17 03:11:07
问题 mongod.log shows: {deliver_area: { $geoIntersects: { $geometry: { type: "Point", coordinates: [ 116.3426399230957, 39.95959281921387 ] } } } } ntoreturn:0 ntoskip:0 nscanned:2965 keyUpdates:0 numYields: 2 locks(micros) r:136723 nreturned:52 reslen:23453 103ms The collection has about 10k records, where deliver_area is one of the fields which is a Polygon(GeoJSON) and has a 2dsphere index This is my query: db.area_coll.find( { id: 59, deliver_area: { $geoIntersects: { $geometry: { type: "Point

Multiple-column index would also be useful for single column?

孤街醉人 提交于 2020-01-17 01:23:14
问题 I'm confused about the order on multiple indexes groups. Take a look at this: . . . WHERE col1 = ? AND col2 = ? AND col3 = ? Well in query above I have to create a three-column index on (col1, col2, col3) . Now I want to know, that multiple-index is useful elsewhere? For example this query: . . . WHERE col1 = ? AND col2 = ? Should I create another two-column index (col1, col2) for this ^ or that three-column index is enough here too? And what about this query: . . . WHERE col2 = ? AND col3 =

Retrieve indexes of multiple values with Numpy in a vectorization way

泪湿孤枕 提交于 2020-01-16 15:48:20
问题 In order to get the index corresponding to the "99" value in a numpy array, we do : mynumpy=([5,6,9,2,99,3,88,4,7)) np.where(my_numpy==99) What if, I want to get the index corresponding to the following values 99,55,6,3,7? Obviously, it's possible to do it with a simple loop but I'm looking for a more vectorization solution. I know Numpy is very powerful so I think it might exist something like that. desired output : searched_values=np.array([99,55,6,3,7]) np.where(searched_values in mynumpy)

Retrieve indexes of multiple values with Numpy in a vectorization way

喜欢而已 提交于 2020-01-16 15:47:47
问题 In order to get the index corresponding to the "99" value in a numpy array, we do : mynumpy=([5,6,9,2,99,3,88,4,7)) np.where(my_numpy==99) What if, I want to get the index corresponding to the following values 99,55,6,3,7? Obviously, it's possible to do it with a simple loop but I'm looking for a more vectorization solution. I know Numpy is very powerful so I think it might exist something like that. desired output : searched_values=np.array([99,55,6,3,7]) np.where(searched_values in mynumpy)

how to configure mongodb index for sorting by value within time range with certain type?

妖精的绣舞 提交于 2020-01-16 14:04:13
问题 I have a collection like below transfer_collection - type - value - from - to - timestamp What I want to extract from the collection is the highest 100 values with certain type within certain time period. For example, db.getCollection('transfer_collection').find({$and:[{"type":"normal"}, {"timestamp":{$gte:ISODate("2018-01-10T00:00:00.000Z")}}, {"timestamp":{$lt:ISODate("2018-01-11T00:00:00.000Z")}}]}).sort({"value":-1}).limit(100) My question is, for query performance, how to make index?

Indexing schema-less dbs having user-defined schemas?

白昼怎懂夜的黑 提交于 2020-01-16 05:36:12
问题 One of the most essential features of any database is query speed. We store data away and want quick access to data that matches our criteria. However, of late, schema-less databases have become popular. It's one thing if we have a schema-less database but there actually is an inferred (in-the-head/in-the-app) schema; it just hasn't been declared formally by the database. On the other hand, let's say we truly need an open database where several users have their own schemas for their own

TSQL not using indexes

爱⌒轻易说出口 提交于 2020-01-16 03:55:07
问题 This is a test senario, made with temporary tables to illustrate the problem. Pretend table @userdata has index on userid and table @users has index on id Why is the first select unable to use index, I assumed it would perform better in 1 subselect than in 2 subselects? Version - Microsoft SQL Server 2008 R2 (RTM) Compatibility level - SQL Server 2000. -- test tables DECLARE @userdata TABLE(info VARCHAR(50), userid INT) DECLARE @users TABLE(id INT, username VARCHAR(20), superuser BIT) -- test

Javascript Array grouping category

依然范特西╮ 提交于 2020-01-15 12:25:09
问题 I have a problem with grouping an array of numeric value: I have values in an array like this var numb = [5,10,11,6,7,18,1,8,2,1,15,12,4,5,3,4,6,7,15,20]; that are then sorted into ascending numerical order var sortedNumb = [1,1,2,3,4,4,5,5,6,6,7,7,8,10,11,12,15,15,18,20]; Now I want to create a group of numbers like 1-4 , 5-8 , 9-12 , 13-16 , 17-20 Is it possible to create groups dynamically, like that? 回答1: Assuming that 1-4, 5-8, 9-12, 13-16, 17-20 grouping means that you want 5 groups,