2D array indexing

In [1]: import numpy as np In [2]: a = np.array([[2,0],[3,0],[3,1],[5,0],[5,1],[5,2]]) In [3]: b = np.zeros((6,3), dtype=”int32″) In [4]: b[a[:,0], a[:,1]] = 10 In [5]: b Out[5]: array([[ 0, 0, 0], [ 0, 0, 0], [10, 0, 0], [10, 10, 0], [ 0, 0, 0], [10, 10, 10]]) Why it works: If you index b … Read more

What does the Indexed Property of a CoreData attribute do?

I would recommend to read this on indexes: http://en.wikipedia.org/wiki/Index_(database).  Simply put, a database engine creates a new structure which keeps the indexed column (which corresponds to a property) sorted and a link to the corresponding row for each entry (primary key). This allows for faster searches (since search in ordered lists is faster than in … Read more

MySQL indices and order

Index order matters when your query conditions only apply to PART of the index. Consider: SELECT * FROM table WHERE first_name=”john” AND last_name=”doe” SELECT * FROM table WHERE first_name=”john” SELECT * FROM table WHERE last_name=”doe” If your index is (first_name, last_name) queries 1 and 2 will use it, query #3 won’t. If your index is … Read more

Subdocument index in mongo

You can do either : > db.collection.ensureIndex({“data.name”: 1,”data.age”:1, “data.job” : 1}) > db.collection.ensureIndex({“data”: 1}) This is discussed in the documentation under indexes-on-embedded-fields and indexes on sub documents The important section of the sub document section is ‘When performing equality matches on subdocuments, field order matters and the subdocuments must match exactly.’ This means that the … Read more

Tables with no Primary Key

When dealing with indexes, you have to determine what your table is going to be used for. If you are primarily inserting 1000 rows a second and not doing any querying, then a clustered index is a hit to performance. If you are doing 1000 queries a second, then not having an index will lead … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)