Use index in ORDER BY query SQLite I have a table that store messages for my Chat app:
CREATE TABLE message (
    currentUserId,
    threadId,
    timestamp,
    message,
    msgType,
    msgState )

Then I used this query to load 20 message for each thread:
SELECT rowid, * FROM message WHERE currentUserId = '123' AND threadId = '456' ORDER BY timestamp LIMIT 50, 20 

So which index should I create to optimize loading speed of this query?
I already try to index in each of these approaches but none of them seem to be working:

timestamp
threadId
(threadId, timestamp)
As ypercube mentioned, you'll want to create your index on all three fields, currentUserId, threadId and timestamp like so: CREATE  INDEX IX_YourIndexName ON message (currentUserId, threadId, timestamp). The reasoning being you should index on all fields in your predicates (JOIN, WHERE, and HAVING clauses) to create a fully covering index (see 1.7 Covering Indices) which would be the currentUserId and threadId in this case. And then also adding the fields from your ORDER BY clause will help sort the index on those fields as well which will reduce the work for sorting when your query runs. For more information on indexing in SQLite.
Note you might even see a slight performance benefit by switching around the order of currentUserId  and threadId in the index definition, assuming the threadId is more unique than the currentUserId in the table. By defining your indexes with the most unique fields first, it improves the selectivity of that index because less values need to be seeked on upfront. So if threadId is more unique of a field, you could try this index definition as well CREATE  INDEX IX_YourIndexName ON message (threadId, currentUserId, timestamp). But unless the difference in uniqueness between threadId and currentUserId is a lot, or you have a lot of data, you probably won't notice much of a difference, so either definition should be equally fine.