indexing

most efficient way to add index to large mysql table

可紊 提交于 2019-12-23 13:53:20
问题 I have a mysql database with a particular table with a little over 6 million rows and no indexes. A simple query such as SELECT ... FROM log ORDER BY log_date ASC will take an unacceptable amount of time. I obviously need to add indexes to the table, but am unsure of the most efficient way to go about this. 1) My first option would be to issue ALTER TABLE log ADD INDEX log_date , but I'm not sure how long it would take... would it take approximately the same length of time as the previous

How to select different columns from each row in nd-array in Python/numpy?

。_饼干妹妹 提交于 2019-12-23 13:26:35
问题 Suppose I have 3 x 2 matrix A = np.arange(3*2).reshape(3,2) and wish to select elements by index array I = [0, 1, 0] to get [[0],[3],[4]] How would I do this? Writing this way A[:,[0,1,0]] gives something completely different (what?) 回答1: What you can do is pass an iterable of the first dimesion value, and an iterable (e.g. a list) of the second dimension. Something like: I = [0, 1, 0] A[range(len(I)),I] This produces: >>> A[range(len(I)),I] array([0, 3, 4]) In case you want it as a 2d array,

MySQL: should I make all columns in my table indexed?

自闭症网瘾萝莉.ら 提交于 2019-12-23 13:06:50
问题 I have a pivot table, well of course every row will be included in a query: mysql> select * from blog_posts as bp join blog_joins as bj on bj.post_id=1 and bj.taxonomy_id=10 and bj.type = 1; Here's my table structure: Is it recommended to make an index for each column? If not, why and what would you recommend? mysql > alter table blog_joins add index pid (post_id); mysql > alter table blog_joins add index tid (taxonomy_id); mysql > alter table blog_joins add index tp (type); 回答1: For that

MySQL: should I make all columns in my table indexed?

五迷三道 提交于 2019-12-23 13:06:05
问题 I have a pivot table, well of course every row will be included in a query: mysql> select * from blog_posts as bp join blog_joins as bj on bj.post_id=1 and bj.taxonomy_id=10 and bj.type = 1; Here's my table structure: Is it recommended to make an index for each column? If not, why and what would you recommend? mysql > alter table blog_joins add index pid (post_id); mysql > alter table blog_joins add index tid (taxonomy_id); mysql > alter table blog_joins add index tp (type); 回答1: For that

Finding a critical point in matrix

↘锁芯ラ 提交于 2019-12-23 12:59:20
问题 I'm attempting to find a critical point in a matrix. The value at index (i,j) should be greater than or equal to all elements in its row, and less than or equal to all elements in its column. Here is what I have (it's off but I'm close): function C = critical(A) [nrow ncol] = size(A); C = []; for i = 1:nrow for j = 1:ncol if (A(i,j) >= A(i,1:end)) && (A(i,j) <= A(1:end,j)) C = [C ; A(i,j)] end end end 回答1: Try this vectorised solution using bsxfun function [ r,c,criP ] = critical( A ) %//

how to populate matrix of indices with vector of values

别等时光非礼了梦想. 提交于 2019-12-23 12:47:07
问题 I have a matrix (m.idx) containing position elements of a vector I want to index. > m.idx [,1] [,2] [,3] [,4] [,5] [1,] 1 2 3 4 5 [2,] 3 4 5 6 7 [3,] 5 6 7 8 9 Suppose x is my vector. x <- c(9,3,2,5,3,2,4,8,9) I want to repopulate the matrix index with the corresponding position elements of x . so I would have... > m.pop [,1] [,2] [,3] [,4] [,5] [1,] 9 3 2 5 3 [2,] 2 5 3 2 4 [3,] 3 2 4 8 9 I can kind of do it in a kludgy way with the following. > m.pop <- t(matrix(t(matrix(x[c(t(m.idx))]))

Please help me with this query (sql server 2008)

痴心易碎 提交于 2019-12-23 12:45:05
问题 ALTER PROCEDURE ReadNews @CategoryID INT, @Culture TINYINT = NULL, @StartDate DATETIME = NULL, @EndDate DATETIME = NULL, @Start BIGINT, -- for paging @Count BIGINT -- for paging AS BEGIN SET NOCOUNT ON; --ItemType for news is 0 ;WITH Paging AS ( SELECT news.ID, news.Title, news.Description, news.Date, news.Url, news.Vote, news.ResourceTitle, news.UserID, ROW_NUMBER() OVER(ORDER BY news.rank DESC) AS RowNumber, TotalCount = COUNT(*) OVER() FROM dbo.News news JOIN ItemCategory itemCat ON

Xcode 4 is not indexing my project

扶醉桌前 提交于 2019-12-23 12:41:14
问题 I have a project where Xcode 4 stopped indexing. As a consequence neither the complete class browser (symbol navigator) nor code sense work. 0 Classes and Protocols etc. are shown. I restarted indexing process by removal of some temporary files in the derived data and the xcodeproj area. But this does not help. Does anyone know what can Xcode prevent from indexing? I rebuilt the whole project and hopefully found the reason: In my-Prefix.pch file I included #import <myheader.h> , where

lucene indexing of html files

a 夏天 提交于 2019-12-23 12:27:46
问题 Dear Users I am working on apache lucene for indexing and searching . I have to index html files stored on the local disc of computer . I have to make indexing on filename and contents of the html files . I am able to store the file names in the lucene index but not the html file contents which should index not only the data but the entire page consisting images link and url and how can i access the contents from those indexed files for indexing i am using the following code: File indexDir =

Zend framework: “url not found” only with index controller, only if lowercase

不羁岁月 提交于 2019-12-23 12:26:42
问题 This is my problem: I have a working zend application running on aruba/linux. It seems to work well. I have some controllers: index, user, video, ... if i type "http://www.foo.com/public/" i can reach my index controller and index action. if i type "http://www.foo.com/public/user/register" i can reach my user controller and register action. if i type "http://www.foo.com/public/index/index" the server return url not found :( But the most strange thing is that if i type "http://www.foo.com