mirror of
https://github.com/librespeed/speedtest.git
synced 2026-10-21 15:51:14 +00:00
perf: index telemetry timestamps
Index timestamp lookups used by telemetry statistics and result listing.
This commit is contained in:
parent
e8dcccf1a8
commit
722689727b
4 changed files with 19 additions and 1 deletions
|
|
@ -138,6 +138,10 @@ function getPdo($returnErrorMessage = false)
|
|||
`log` longtext
|
||||
);
|
||||
');
|
||||
// Every query that is not a lookup by id orders or filters by
|
||||
// timestamp, and without this the table is scanned in full each
|
||||
// time. The other schemas declare the same index.
|
||||
$pdo->exec('CREATE INDEX IF NOT EXISTS `speedtest_users_timestamp` ON `speedtest_users` (`timestamp`);');
|
||||
|
||||
return $pdo;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,4 +33,10 @@ GO
|
|||
ALTER TABLE [dbo].[speedtest_users] ADD CONSTRAINT [DF_speedtest_users_timestamp] DEFAULT (getdate()) FOR [timestamp]
|
||||
GO
|
||||
|
||||
CREATE NONCLUSTERED INDEX [speedtest_users_timestamp] ON [dbo].[speedtest_users]
|
||||
(
|
||||
[timestamp] ASC
|
||||
) ON [PRIMARY]
|
||||
GO
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ CREATE TABLE `speedtest_users` (
|
|||
-- Indexes for table `speedtest_users`
|
||||
--
|
||||
ALTER TABLE `speedtest_users`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `speedtest_users_timestamp` (`timestamp`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for dumped tables
|
||||
|
|
|
|||
|
|
@ -107,6 +107,13 @@ ALTER TABLE ONLY speedtest_users
|
|||
ADD CONSTRAINT speedtest_users_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: speedtest_users_timestamp; Type: INDEX; Schema: public; Owner: speedtest
|
||||
--
|
||||
|
||||
CREATE INDEX speedtest_users_timestamp ON speedtest_users USING btree ("timestamp");
|
||||
|
||||
|
||||
--
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue