All Questions

286
votes
9answers
51448 views

How can I index a MATLAB array returned by a function without first assigning it to a local variable?

For example, if I want to read the middle value from magic(5), I can do so like this: M = magic(5); value = M(3,3); to get value == 13. I'd like to be able to do something like one of these: value...
1650
votes
9answers
589949 views

How does database indexing work?

Given that indexing is so important as your data set increases in size, can someone explain how does indexing work at a database-agnostic level? For information on queries to index a field, check out...
1907
votes
20answers
2111575 views

Finding the index of an item given a list containing it in Python

For a list ["foo", "bar", "baz"] and an item in the list "bar", what's the cleanest way to get its index (1) in Python?
94
votes
7answers
119729 views

With MySQL, how can I generate a column containing the record index in a table?

Is there any way I can get the actual row number from a query? I want to be able to order a table called league_girl by a field called score; and return the username and the actual row position of th...
27
votes
3answers
18812 views

Optimize GROUP BY query to retrieve latest record per user

I have the following table (simplified form) in Postgres 9.2 CREATE TABLE user_msg_log ( aggr_date DATE, user_id INTEGER, running_total INTEGER ); It contains up to one record per user ...
105
votes
17answers
128601 views

How do you reindex an array in PHP?

I have the following array, which I would like to reindex so the keys are reversed (ideally starting at 1): Current array (edit: the array actually looks like this): Array ( [2] => Object ( ...
72
votes
5answers
46270 views

PostgreSQL LIKE query performance variations

I have been seeing quite a large variation in response times regarding LIKE queries to a particular table in my database. Sometimes I will get results within 200-400 ms (very acceptable) but other tim...
246
votes
8answers
532253 views

Replace a character at a specific index in a string?

I'm trying to replace a character at a specific index in a string. What I'm doing is: String myName = "domanokz"; myName.charAt(4) = 'x'; This gives an error. Is there any method to do this?
715
votes
8answers
504274 views

What do Clustered and Non clustered index actually mean?

I have a limited exposure to DB and have only used DB as an application programmer. I want to know about Clustered and Non clustered indexes. I googled and what I found was : A clustered index is ...
56
votes
1answers
29992 views

Index for finding an element in a JSON array

I have a table that looks like this: CREATE TABLE tracks (id SERIAL, artists JSON); INSERT INTO tracks (id, artists) VALUES (1, '[{"name": "blink-182"}]'); INSERT INTO tracks (id, artists) VA...

Previous Next