From 5aad67c6cee779b22422a9bdeaefe35d1084d5fb Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 26 Dec 2024 17:15:04 +0600 Subject: [PATCH 1/2] feat: add optimize recommendation to avoid current_time --- content/700-optimize/300-recordings.mdx | 1 + .../400-recommendations/1000-current-time.mdx | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 content/700-optimize/400-recommendations/1000-current-time.mdx diff --git a/content/700-optimize/300-recordings.mdx b/content/700-optimize/300-recordings.mdx index 847a1b893b..28d2a88051 100644 --- a/content/700-optimize/300-recordings.mdx +++ b/content/700-optimize/300-recordings.mdx @@ -44,6 +44,7 @@ When a recording session ends, Optimize generates recommendations such as: - [Using `@db.Money`](/optimize/recommendations/avoid-db-money) - [Using `@db.VarChar(n)`](/optimize/recommendations/avoid-varchar) - [Using `timestamp(0)` or `timestamptz(0)`](/optimize/recommendations/avoid-timestamp-timestampz-0) +- [Using `CURRENT_TIME`](/optimize/recommendations/current-time) :::info Use [Prisma AI](/optimize/prisma-ai) to ask follow-up questions about a recommendation. diff --git a/content/700-optimize/400-recommendations/1000-current-time.mdx b/content/700-optimize/400-recommendations/1000-current-time.mdx new file mode 100644 index 0000000000..abc48c7df4 --- /dev/null +++ b/content/700-optimize/400-recommendations/1000-current-time.mdx @@ -0,0 +1,17 @@ +--- +title: 'Using CURRENT_TIME' +metaTitle: 'Optimize Recommendations: Avoid usage of `CURRENT_TIME`' +metaDescription: 'Learn about the recommendation provided by Optimize for using the `CURRENT_TIME` function' +tocDepth: 2 +toc: true +--- + +The following raw SQL query uses the `CURRENT_TIME` function: + +```ts +prisma.$queryRaw`SELECT CURRENT_TIME;` +``` + +### Why this is a problem + +The `CURRENT_TIME` keyword returns only the time (e.g., 14:30:00) without a date, making it unsuitable for tasks like logging or timestamping that require precise event tracking. It returns a value of type `timetz`, which was added for SQL standard compatibility but is generally discouraged. From f636312a6814036b97fe91a5537177deae2bad4b Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Thu, 26 Dec 2024 19:00:00 +0600 Subject: [PATCH 2/2] fix: spelling mistakes --- content/700-optimize/400-recommendations/1000-current-time.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/700-optimize/400-recommendations/1000-current-time.mdx b/content/700-optimize/400-recommendations/1000-current-time.mdx index abc48c7df4..493f009066 100644 --- a/content/700-optimize/400-recommendations/1000-current-time.mdx +++ b/content/700-optimize/400-recommendations/1000-current-time.mdx @@ -14,4 +14,4 @@ prisma.$queryRaw`SELECT CURRENT_TIME;` ### Why this is a problem -The `CURRENT_TIME` keyword returns only the time (e.g., 14:30:00) without a date, making it unsuitable for tasks like logging or timestamping that require precise event tracking. It returns a value of type `timetz`, which was added for SQL standard compatibility but is generally discouraged. +The `CURRENT_TIME` keyword returns only the time (e.g., 14:30:00) without a date, making it unsuitable for tasks like logging or generating timestamps that require precise event tracking. It returns a value of type `timetz`, which was added for SQL standard compatibility but is generally discouraged.