6

I am developing an android application and using SQLite. I wonder that:

  • What is the time complexity of INSERT, UPDATE and SELECT operations. (I would be happy if the answer will be in terms of BigO notation but other answers are also welcome.)

  • What is the CPU usage?

NuSkooler
  • 5,391
  • 1
  • 34
  • 58
abidinberkay
  • 1,857
  • 4
  • 36
  • 68
  • 1
    I believe they are `O(m x log(n))` where `m` is the number of records you want to insert, update, or retrieve and `n` is the number of records in the database. – David Schwartz Apr 09 '13 at 08:03
  • do you have any idea about cpu usage ? – abidinberkay Apr 09 '13 at 08:23
  • I don't know how to answer that question. Everyone uses SQLite on Android. So if you use it properly, it should work as well for you as it does for everyone else. Other than that, your question about CPU usage is too vague to give a specific answer to. – David Schwartz Apr 09 '13 at 08:24
  • ahh you are right dude, cpu usage of SELECT. just an approximation is enough. – abidinberkay Apr 09 '13 at 08:29
  • 2
    Depending on how many user-defined functions and triggers you use, and on how complex the queries are, the answer could be anything from O(1) to O(∞). Specific answer can be given only for specific queries and specific databases. – CL. Apr 09 '13 at 16:33

1 Answers1

3

Both questions are really too vague to answer, but this may help:

Time Complexity:

Given a particular SQL statement you could perhaps figure the time and complexity, but there are simply too many factors to point to a single answer.

You might be interested in EXPLAIN QUERY PLAN which can help you with particular SELECTs.

CPU Usage:

Again, CPU usage of what exactly? Complex queries may hit the CPU a bit more, but I think you'll find most of the work is I/O.

NuSkooler
  • 5,391
  • 1
  • 34
  • 58