-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsql_queries.html
More file actions
203 lines (184 loc) · 7.38 KB
/
Copy pathsql_queries.html
File metadata and controls
203 lines (184 loc) · 7.38 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="version" content="3.16.3" />
<meta name="last-updated" content="2025-09-29" />
<title>Advanced SQL++ Queries - Couchbase Query Analyzer v3.16.3</title>
<meta name="description" content="Advanced SQL++ queries for extracting and filtering Couchbase system:completed_requests data for slow query analysis." />
<link rel="icon" type="image/svg+xml" href="img/favicon.svg" />
<style>
/* Match index.html styles */
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
line-height: 1.6;
color: #333;
max-width: 1000px;
margin: 0 auto;
padding: 20px;
background: #f5f7fa;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
header {
text-align: center;
padding: 5px 20px;
background: linear-gradient(135deg, #007acc 0%, #00b4d8 100%);
color: white;
border-radius: 12px;
margin-bottom: 20px;
box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}
h1 { font-size: 2.2em; margin: 0; letter-spacing: 0.2px; }
h2 { font-size: 1.8em; color: #007acc; margin-top: 40px; position: relative; }
/* Section title accent */
h2::after { content: ""; display: block; width: 56px; height: 3px; background: #00b4d8; border-radius: 2px; margin-top: 8px; }
h3 { color: #2d3748; margin-top: 24px; }
p.intro { color: #4a5568; margin: 10px auto 18px; max-width: 760px; }
/* Match original SQL query box + copy button look & feel */
.sql-query-box{background:#f8f9fa;border:1px solid #dee2e6;border-radius:8px;padding:15px;margin:15px 0;position:relative;box-shadow:0 2px 8px rgba(0,0,0,0.05)}
.sql-query-box pre{background:#ffffff;border:1px solid #e9ecef;border-radius:6px;padding:10px;margin:10px 0;font-family:monospace;font-size:12px;line-height:1.5;overflow-x:auto}
.sql-copy-btn{position:absolute;top:10px;right:10px;background:#007bff;color:white;border:none;border-radius:6px;padding:6px 12px;font-size:11px;cursor:pointer;box-shadow:0 2px 6px rgba(0,0,0,0.12);transition: background 0.2s ease, transform 0.2s ease}
.sql-copy-btn:hover{background:#0056b3;transform: translateY(-1px)}
/* Floating GitHub icon like the original */
.floating-github{position:fixed;bottom:10px;right:10px;z-index:999;text-align:center}
.floating-github img{width:40px;height:40px;filter: drop-shadow(0 2px 6px rgba(0,0,0,0.2))}
.floating-github .copyright{margin-top:6px;font-size:12px;color:#777}
/* Version badge (parity with original) */
.version-info{position:fixed;bottom:10px;left:10px;background:rgba(0,0,0,0.1);color:#333;padding:4px 8px;border-radius:4px;font-size:0.75em;font-family:monospace;z-index:999;opacity:0.7;transition:opacity 0.3s ease}
.version-info:hover{opacity:1;background:rgba(0,0,0,0.2)}
footer { text-align: center; padding: 20px; font-size: 0.9em; color: #666; border-top: 1px solid #eaeef2; margin-top: 30px; }
footer a { color: #007acc; text-decoration: none; }
footer a:hover { text-decoration: underline; }
/* Accessible focus styles */
a:focus-visible, button:focus-visible { outline: 3px solid rgba(0,122,204,0.35); outline-offset: 2px; border-radius: 6px; }
@media (max-width: 600px) {
body { padding: 10px; }
h1 { font-size: 2em; }
}
</style>
</head>
<body>
<!-- Floating GitHub link (matches original positioning/appearance) -->
<div class="floating-github">
<a href="https://github.com/Fujio-Turner/cb_completed_request" target="_blank" rel="noopener noreferrer">
<img src="https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" alt="GitHub repository for Couchbase slow query analysis tool" />
</a>
<div class="copyright">© 2025 fuj.io</div>
</div>
<header>
<h1>Advanced SQL++ Queries</h1>
<p style="margin:6px 0 0">Targeted filters for system:completed_requests to speed up data extraction and analysis</p>
</header>
<main>
<p class="intro">
Use these SQL++ examples to extract targeted results from <code>system:completed_requests</code> — by node, by date range, and by excluding system-generated statements —
so you can focus on the most relevant queries during analysis.
</p>
<h2>Common Filters</h2>
<h3>Remove system-level queries</h3>
<div class="sql-query-box">
<pre>SELECT
*,
meta().plan
FROM
system:completed_requests
WHERE
clientContextID NOT LIKE 'INTERNAL-%' AND
UPPER(IFMISSING(preparedText, statement)) NOT LIKE 'INFER %' AND
UPPER(IFMISSING(preparedText, statement)) NOT LIKE 'ADVISE %' AND
UPPER(IFMISSING(preparedText, statement)) NOT LIKE 'CREATE %' AND
UPPER(IFMISSING(preparedText, statement)) NOT LIKE 'CREATE INDEX%' AND
UPPER(IFMISSING(preparedText, statement)) NOT LIKE 'ALTER INDEX%' AND
UPPER(IFMISSING(preparedText, statement)) NOT LIKE '% SYSTEM:%'
LIMIT
2000;</pre>
<button class="sql-copy-btn">Copy</button>
</div>
<h3>Search within SQL strings</h3>
<div class="sql-query-box">
<pre>SELECT
*,
meta().plan
FROM
system:completed_requests
WHERE
CONTAINS(`statement`,"SELECT *")
OR
CONTAINS(preparedText,"SELECT *")
ORDER BY
requestId
LIMIT
2000;</pre>
<button class="sql-copy-btn">Copy</button>
</div>
<h3>Between two dates</h3>
<div class="sql-query-box">
<pre>SELECT
*,
meta().plan
FROM
system:completed_requests
WHERE
requestTime BETWEEN "2025-06-01" AND "2025-08-02";</pre>
<button class="sql-copy-btn">Copy</button>
</div>
<h2>By Node</h2>
<h3>Current query node</h3>
<div class="sql-query-box">
<pre>SELECT
*,
meta().plan
FROM
system:completed_requests
WHERE
node = NODE_NAME()
LIMIT
2000;</pre>
<button class="sql-copy-btn">Copy</button>
</div>
<h3>Specific query node</h3>
<div class="sql-query-box">
<pre>SELECT
*,
meta().plan
FROM
system:completed_requests
WHERE
node LIKE "10.132.133.165%"
LIMIT
2000;</pre>
<button class="sql-copy-btn">Copy</button>
</div>
<p class="intro" style="margin-top:24px">
Source: <code>sql_queries.md</code>. For broader guidance, see the
<a href="analysis_hub.html" target="_blank" rel="noopener noreferrer">Analysis Hub</a>
or return to the <a href="en/index.html" target="_blank" rel="noopener noreferrer">Analyzer</a>.
</p>
</main>
<div class="version-info">Couchbase Slow Query Analysis Tool v3.16.3</div>
<footer>
<p>© 2025 <a href="https://fuj.io" target="_blank" rel="noopener noreferrer">fuj.io</a>.</p>
</footer>
<script>
// Match original Copy behavior (button text + green success color)
document.querySelectorAll('.sql-copy-btn').forEach(button => {
button.addEventListener('click', () => {
const code = button.parentElement.querySelector('pre').textContent;
navigator.clipboard.writeText(code).then(() => {
button.style.background = '#28a745';
const prevText = button.textContent;
button.textContent = 'Copied!';
setTimeout(() => {
button.textContent = prevText;
button.style.background = '';
}, 2000);
}).catch(err => {
console.error('Failed to copy: ', err);
});
});
});
</script>
</body>
</html>