indexing

Why does dropping an index take longer than creating it?

那年仲夏 提交于 2019-12-21 03:48:13
问题 In postgresql, I added an index to a large table, and it took about 1 second (which, frankly, surprised me). When I went to drop the index, I let it run for >200 seconds without it returning, and finally cancelled the drop operation. CREATE INDEX idx_cservicelocationdivisionstatus_inversed ON cservicelocationdivisionstatus (cservicelocationdivisionid, startdate, enddate DESC); Takes very little time, but DROP INDEX idx_cservicelocationdivisionstatus_inversed; Took so long that I gave up and

How to check a SQL Server CE database for indexes?

放肆的年华 提交于 2019-12-21 03:45:39
问题 Is there a way to list all SQL Server CE database table indexes, or at least for individual tables? 回答1: -- Retrieves information about the indexes contained in the database. SELECT * FROM INFORMATION_SCHEMA.INDEXES -- Retrieves all the Tables in the database including the System tables. SELECT * FROM INFORMATION_SCHEMA.TABLES Arjuna Chiththananda - Retrieving Schema Information of SQL CE Database 回答2: Thank you Arjuna! you pointed me in the right direction..... The following works. SELECT 'Y

swift 3 get start index (as int) of substring

浪尽此生 提交于 2019-12-21 03:38:09
问题 I would like to get the start and end position of a substring within a string. Example: in the string "hi this is my name"; if I provide the string "this" I would like to know the start index is 4 and end index is 7. I found several links, including this one: Swift: get index of start of a substring in a string a-substring-in-a-string But it doesn´t work in swift 3 as the method is now called range. I am now using this: let range = mystring.range(of: "StringSearch")?.lowerBound which returns

How-to index arrays (tags) in CouchDB using couchdb-lucene

喜欢而已 提交于 2019-12-21 02:45:10
问题 The setup: I have a project that is using CouchDB. The documents will have a field called "tags". This "tags" field is an array of strings (e.g., "tags":["tag1","tag2","etc"]). I am using couchdb-lucene as my search provider. The question: What function can be used to get couchdb-lucene to index the elements of "tags"? If you have an idea but no test environment, type it out, I'll try it and give the result here. 回答1: Well it was quite easy after I figured it out. Please realize that the $

How to create text index for '%abc%' search?

五迷三道 提交于 2019-12-21 01:59:05
问题 I'd like to index queries like x like '%abc%' If I have a table like the following create table t ( data varchar(100) ); I want to create an index to be able to do the following efficiently: select * from t where contains('%abc%'); And this: select * from t where contains('abc%'); I also want this table to be updated live. How do I create such an index? (I have a feeling I need a ctxcat index, but I'm confused about what options I need to give it) I'm using Oracle 10g. 回答1: I would use this

Numpy Lookup (Map, or Point)

帅比萌擦擦* 提交于 2019-12-20 23:59:14
问题 I have a large numpy array: array([[32, 32, 99, 9, 45], # A [99, 45, 9, 45, 32], [45, 45, 99, 99, 32], [ 9, 9, 32, 45, 99]]) and a large-ish array of unique values in a particular order: array([ 99, 32, 45, 9]) # B How can I quickly (no python dictionaries, no copies of A , no python loops) replace the values in A so that become the indicies of the values in B ?: array([[1, 1, 0, 3, 2], [0, 2, 3, 2, 1], [2, 2, 0, 0, 1], [3, 3, 1, 2, 0]]) I feel reaaly dumb for not being able to do this off

Leave out discriminator part of Doctrine' generated SQL

南笙酒味 提交于 2019-12-20 20:39:16
问题 Assume the following AbstractPage model: /* * @ORM\Entity * @ORM\Table(name="page") * @ORM\InheritanceType("SINGLE_TABLE") * @ORM\DiscriminatorColumn(name="type", type="string") * @ORM\DiscriminatorMap * ({ * "page" = "Page", * "link" = "Link" * }) */ And the following DQL query: SELECT p FROM \Page\Model\AbstractPage The generated SQL will be: SELECT ... FROM page p0_ WHERE p0_.type IN ('page', 'link') Now to the question: how can I remove the WHERE clause from this query. On more complex

indexing and query high dimensional data in postgreSQL

╄→гoц情女王★ 提交于 2019-12-20 18:30:15
问题 I want to index data in height dimensions (128 dimensional vectors of integers in range of [0,254] are possible): | id | vector | | 1 | { 1, 0, ..., 254} | | 2 | { 2, 128, ...,1} | | . | { 1, 0, ..., 252} | | n | { 1, 2, ..., 251} | I saw that PostGIS implemented R-Trees. So can I use these trees in PostGIS to index and query multidimensional vectors in Postgres? I also saw that there is a index implementation for int arrays. Now I have questions about how to perform a query. Can I perform a

How do I subtract the previous row from the current row in a pandas dataframe and apply it to every row; without using a loop?

倾然丶 夕夏残阳落幕 提交于 2019-12-20 18:14:05
问题 I am using Python3.5 and I am working with pandas. I have loaded stock data from yahoo finance and have saved the files to csv. My DataFrames load this data from the csv. This is a copy of the ten rows of the csv file that is my DataFrame Date Open High Low Close Volume Adj Close 1990-04-12 26.875000 26.875000 26.625 26.625 6100 250.576036 1990-04-16 26.500000 26.750000 26.375 26.750 500 251.752449 1990-04-17 26.750000 26.875000 26.750 26.875 2300 252.928863 1990-04-18 26.875000 26.875000 26

Grails multi column indexes

萝らか妹 提交于 2019-12-20 18:01:52
问题 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