Commit a8c0c66
Optimize social media links and add database warmup
Social Media Links (7 queries -> 1 query):
- Load all social media links in a single query using WHERE IN
- Memoize results to avoid repeated queries within same request
- Add clear_social_media_cache method for cache invalidation
Database Warmup:
- Add initializer to pre-warm database connection on boot
- Executes SELECT 1 and preloads first website in production
- Moves PostgreSQL type mapping overhead from first request to boot
Before: 28 queries, 280ms
After: 25 queries, 257ms
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 0f5374b commit a8c0c66
File tree
3 files changed
+90
-18
lines changed- app/models/concerns
- pwb
- website
- config/initializers
3 files changed
+90
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
12 | 32 | | |
13 | | - | |
| 33 | + | |
14 | 34 | | |
15 | 35 | | |
16 | 36 | | |
17 | | - | |
| 37 | + | |
18 | 38 | | |
19 | 39 | | |
20 | 40 | | |
21 | | - | |
| 41 | + | |
22 | 42 | | |
23 | 43 | | |
24 | 44 | | |
25 | | - | |
| 45 | + | |
26 | 46 | | |
27 | 47 | | |
28 | 48 | | |
29 | | - | |
| 49 | + | |
30 | 50 | | |
31 | 51 | | |
32 | 52 | | |
33 | | - | |
| 53 | + | |
34 | 54 | | |
35 | 55 | | |
36 | 56 | | |
37 | | - | |
| 57 | + | |
38 | 58 | | |
39 | 59 | | |
40 | 60 | | |
41 | 61 | | |
42 | | - | |
43 | | - | |
44 | 62 | | |
45 | 63 | | |
46 | 64 | | |
47 | | - | |
| 65 | + | |
48 | 66 | | |
49 | 67 | | |
50 | 68 | | |
| |||
63 | 81 | | |
64 | 82 | | |
65 | 83 | | |
66 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
67 | 87 | | |
68 | 88 | | |
69 | 89 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
12 | 32 | | |
13 | | - | |
| 33 | + | |
14 | 34 | | |
15 | 35 | | |
16 | 36 | | |
17 | | - | |
| 37 | + | |
18 | 38 | | |
19 | 39 | | |
20 | 40 | | |
21 | | - | |
| 41 | + | |
22 | 42 | | |
23 | 43 | | |
24 | 44 | | |
25 | | - | |
| 45 | + | |
26 | 46 | | |
27 | 47 | | |
28 | 48 | | |
29 | | - | |
| 49 | + | |
30 | 50 | | |
31 | 51 | | |
32 | 52 | | |
33 | | - | |
| 53 | + | |
34 | 54 | | |
35 | 55 | | |
36 | 56 | | |
37 | | - | |
| 57 | + | |
38 | 58 | | |
39 | 59 | | |
40 | 60 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
0 commit comments