> On 12 Sep 2015, at 9:12pm, Aurel Wisse <aurel.wisse at gmail.com> wrote:
> 
> CREATE TEMP TABLE offsets AS
> 
>  WITH RECURSIVE dtoff(calc_date, tmw) AS (
> 
> WITH dates AS (SELECT DISTINCT calc_date FROM securities)
> 
>    SELECT NULL, (SELECT min(calc_date) FROM dates)
> ...
> This is inevitable as "securities" is a table with 6.2 million rows. This
> is the schema:
> 
> CREATE TABLE security (calc_date TEXT, security_code INT, mx_full REAL,
> mx_adj REAL, mx_std REAL, fu_full REAL, fu_adj REAL, few_full REAL, few_adj
> REAL);
> 
> 
> There are about 4000 distinct calc_date in securities.

Do you have an index on calc_date ?  If not, make one.

Simon.

Reply via email to