Skip to content

Commit 7c04f4c

Browse files
committed
remove recursive query from default index
1 parent f76c9dd commit 7c04f4c

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

index.sql

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,14 @@ select 'Brasil',
6565
select 'chart' as component,
6666
'Collatz conjecture' as title,
6767
'area' as type;
68-
WITH RECURSIVE cnt(x, y) AS (
69-
SELECT 0, 15
70-
UNION ALL
71-
SELECT x + 1,
72-
CASE
73-
y %2
74-
WHEN 0 THEN y / 2
75-
ELSE 3 * y + 1
76-
END
77-
FROM cnt
78-
WHERE x < 12
79-
)
68+
8069
SELECT 'syracuse' as series,
8170
x,
8271
y
83-
from cnt;
72+
FROM (
73+
VALUES (0, 15), (1, 46), (2, 23), (3, 70), (4, 35), (5, 106), (6, 53), (7, 160), (8, 80), (9, 40), (10, 20), (11, 10), (12, 5)
74+
) AS cnt(x, y);
75+
8476
select 'table' as component,
8577
true as sort,
8678
true as search;
@@ -96,14 +88,7 @@ select 'Jane',
9688
-- We will display a set of cards, each one displaying the result of the multiplication a * b
9789
select 'card' as component,
9890
5 as columns;
99-
WITH RECURSIVE cnt(x) AS (
100-
-- cnt is a table that contains the numbers from 1 to 10
101-
SELECT 1
102-
UNION ALL
103-
SELECT x + 1
104-
FROM cnt
105-
WHERE x < 10
106-
)
91+
10792
SELECT a.x || ' times ' || b.x as title,
10893
CASE
10994
a.x % 4
@@ -115,8 +100,8 @@ SELECT a.x || ' times ' || b.x as title,
115100
a.x || ' x ' || b.x || ' = ' || (a.x * b.x) as description,
116101
'This is basic math' as footer,
117102
'?x=' || a.x as link -- This is the interesting part. Each card has a link. When you click the card, the current page is reloaded with '?x=a' appended to the end of the URL
118-
FROM cnt as a,
119-
cnt as b
103+
FROM (VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12)) as a(x),
104+
(VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12)) as b(x)
120105
WHERE -- The powerful thing is here
121106
$x IS NULL
122107
OR -- The syntax $x allows us to extract the value 'a' when the URL ends with '?x=a'. It will be null if the URL does not contain '?x='

0 commit comments

Comments
 (0)