[prev in list] [next in list] [prev in thread] [next in thread]
List: sqlite-users
Subject: Re: [sqlite] View - What happens internally
From: Dan <danielk1977 () gmail ! com>
Date: 2009-02-28 14:37:45
Message-ID: A77E23B7-9671-4D3E-A346-D58FF6C80E0D () gmail ! com
[Download RAW message or body]
On Feb 28, 2009, at 8:44 PM, Lloyd wrote:
>
> Hi,
>
> When we create a view what happens internally in sqlite? Does it
> select
> all the data from the table and then "insert" it in to the view? or
> would
> the records in the view keep references to records in main table?
> just to
> know whether creating more views on a big in-memory database would
> require
> more memory.
A view in SQLite is just a SELECT statement that is saved in the
database
schema. If you do:
CREATE VIEW v1 AS SELECT * FROM t1;
SELECT * FROM v1;
The SQL compiler (the thing that runs when you call
sqlite3_prepare_v2())
converts the select statement to "SELECT * FROM (SELECT * FROM t1)"
before compiling a prepared statement to implement the query.
So adding a view doesn't require a huge amount of extra memory.
Dan.
>
>
> Thanks,
> Lloyd
>
> ______________________________________
> Scanned and protected by Email scanner
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic