indexing

How to choose indexes for chat application database

给你一囗甜甜゛ 提交于 2020-01-02 07:41:53
问题 I work on a small chat application with database. I create the database shown in the image. I new to indexes and I want to choose the appropriate indexes for the query. Can I use clustered index in the Messages table ? and if I can, Which column (or columns) should have clustered index ? or should I use non-clustered index ? Update : The query that I user to get messages is : Select TextContent From Messages where (SenderId='1' and ReciverID = '2') or (SenderId='2' and ReciverID = '1') order

Sql Server ignores index on varchar column and does tablescan when queried from Java

╄→гoц情女王★ 提交于 2020-01-02 06:58:27
问题 QUESTION: I have a SQL Server table with one varchar column and millions of rows, it is indexed. Running a query from within SQL Server query tool is quick as it uses the index. When I run a query from Java JDBC PreparedStatement it takes many minutes and investigation shows SQL Server does a tablescan. How do I fix this problem? 回答1: ANSWER: The problem results from Java passing a unicode string for the query parameter to SQLServer. SQLServer will not use this on a varchar index. If you want

Sql Server ignores index on varchar column and does tablescan when queried from Java

萝らか妹 提交于 2020-01-02 06:58:06
问题 QUESTION: I have a SQL Server table with one varchar column and millions of rows, it is indexed. Running a query from within SQL Server query tool is quick as it uses the index. When I run a query from Java JDBC PreparedStatement it takes many minutes and investigation shows SQL Server does a tablescan. How do I fix this problem? 回答1: ANSWER: The problem results from Java passing a unicode string for the query parameter to SQLServer. SQLServer will not use this on a varchar index. If you want

Getting the three smallest values per row and returning the correspondent column names

做~自己de王妃 提交于 2020-01-02 06:42:15
问题 I have two dataframe, df and df2,they are correspondent. Now based in the first dataframe df, I want to get the 3 smallest value in one row and return the correspondent column's name(in this case like "X"or"Y"or"Z"or"T"). So I can get the new dataframe df3. df = pd.DataFrame({ 'X': [21, 2, 43, 44, 56, 67, 7, 38, 29, 130], 'Y': [101, 220, 330, 140, 250, 10, 207, 320, 420, 50], 'Z': [20, 128, 136, 144, 312, 10, 82, 63, 42, 12], 'T': [2, 32, 4, 424, 256, 167, 27, 38, 229, 30] }, index=list(

Solr, block updating of existing document

别等时光非礼了梦想. 提交于 2020-01-02 06:40:34
问题 When a document is sent to solr and such document already exists in the index (by its ID) then the new one replaces old one. But I don't want to automatically replace documents. Just ignore and proceed to the next. How can I configure solr. Of course I can query solr to check if it has the document already but it's bad for me since I do bulk updates and this will complicate the process and increase amount of request. So are there any ways to configure solr to ignore duplicates? 回答1: You can

TensorFlow, batchwise indexing (first dimension) and sorting

和自甴很熟 提交于 2020-01-02 06:10:14
问题 I've got a params tensor with shape (?,368,5) , as well as a query tensor with shape (?,368) . The query tensor stores indices for sorting the first tensor. The required output has shape: (?,368,5) . Since I need it for a loss function in a neural network, the used operations should stay differentiable. Also, at runtime the size of the first axis ? corresponds to the batchsize. So far I experimented with tf.gather and tf.gather_nd , however tf.gather(params,query) results in a tensor with

Do mysql composite indexes make some other indexes completely redundant?

大城市里の小女人 提交于 2020-01-02 04:56:08
问题 If I have an a composite index on (a, b) I understand that queries only concerned with 'a' will still use the composite index (but not queries concerned with 'b') My question is whether there is any valid reason to have a single-column index on 'a' if I have the (a, b) index? What I've read has seemed vague as to whether the (a,b) index was a complete substitute for a, or merely a "better than nothing" index. This assumes that I do filtering by both a and a,b. I have a table with way too many

Index over multiple lookup tables in SQL Server

大憨熊 提交于 2020-01-02 04:56:07
问题 In SQL Server 2012, let's have three tables: Foos, Lookup1 and Lookup2 created with the following SQL: CREATE TABLE Foos ( Id int NOT NULL, L1 int NOT NULL, L2 int NOT NULL, Value int NOT NULL, CONSTRAINT PK_Foos PRIMARY KEY CLUSTERED (Id ASC) ); CREATE TABLE Lookup1 ( Id int NOT NULL, Name nvarchar(50) NOT NULL, CONSTRAINT PK_Lookup1 PRIMARY KEY CLUSTERED (Id ASC), CONSTRAINT IX_Lookup1 UNIQUE NONCLUSTERED (Name ASC) ); CREATE TABLE Lookup2 ( Id int NOT NULL, Name nvarchar(50) NOT NULL,

MySQL when can I use HASH instead of BTREE

无人久伴 提交于 2020-01-02 04:05:21
问题 Since MySQL uses BTREE by default when creating an index, is there some instance when I can use HASH ? For example, if my table only consists of Foreign Keys which are just INT UNSIGNED values. Is it a good improvement to override BTREE with HASH in this case? Not sure if it matters, but I'm using InnoDB . 回答1: The HASH index type is only supported for MEMORY (aka HEAP ) storage engine. 来源: https://stackoverflow.com/questions/14418260/mysql-when-can-i-use-hash-instead-of-btree

MySQL when can I use HASH instead of BTREE

╄→гoц情女王★ 提交于 2020-01-02 04:05:08
问题 Since MySQL uses BTREE by default when creating an index, is there some instance when I can use HASH ? For example, if my table only consists of Foreign Keys which are just INT UNSIGNED values. Is it a good improvement to override BTREE with HASH in this case? Not sure if it matters, but I'm using InnoDB . 回答1: The HASH index type is only supported for MEMORY (aka HEAP ) storage engine. 来源: https://stackoverflow.com/questions/14418260/mysql-when-can-i-use-hash-instead-of-btree