Postgres (Supabase) SQL - Save the number of records between dates
1 .It is necessary to effectively insert in usages (it is when you triggered the API and recorded activity), by user_id in the user_activity table to record the number of usages that have created_at between current_period_start and current_period_end from the subscription with the status active or trialing.If there is no such signature, you need to remove all usages of the user (so that if he has canceled the signature, then executions_amount_used has been taken for the entire period that is in the usages table).You do not need to use count(), you need to use estimates and the function https://wiki.postgresql.org/wiki/Count_estimate. This feature is already available and it works, but the request somehow releases random data when the filter is on a date.This may be quick fix, but you may need to re-create the trigger logic (it is also a matter of fact).If there are the best suggestions to do this, it would be great to hear.But we don’t need to count on each API call by usages (the table is big), so the API call looks only on the user_activity table and there must be relevant numbers and everything.Look carefully on the screen change of the sign < > does not work at all, but it does not take into account the date.It can also issue usage not from the beginning of the signature date, although all dates in UTC in the database.Therefore, there is a disynchron, if the signature is updated, it draws usages from an irrelevant date to current_period_start, and should only be after current_period_start.This should also be fixed.
Applications 4
-
949 22 0 Good day .
Databases are the main specialization. There are ideas to solve your problem.
-
Якщо вам не потрібен точний підрахунок, поточна статистика з таблиці каталогу
pg_classможе бути достатньо хорошою, і її набагато швидше отримати для великих таблиць.Воно і буде показувати не точний підрахунок. Краще вірно побудувати індекси, тоді і підрахунок буде швидким.
-
Кількість живих рядків у таблиці. Це лише оцінка, яку використовує планувальник. Вона оновлюється командами VACUUM, ANALYZE та деякими командами DDL, такими як CREATE INDEX.
-
Але нам не потрібно на кожен API call робити count по usages (таблиця велика),
ну так зробіть таблицю, де буде пораховано на початок і при кожній вставці - оновляти дані. буде більш-меньш точно і швидко
-
Я бы использовал MATERIALIZED VIEW что обновляется по расписанию
-
Current freelance projects in the category Databases & SQL
Accounting, planning, and sales system for a mushroom farm
600 USD
Here is the complete, final text of the Technical Assignment (TA). It combines all your requirements: 16 chambers, 20 contractors, a schedule by days, accounting for containers, profitability calculation, and a mandatory division into three grades of mushrooms. You can fully… Databases & SQL, Client Management & CRM ∙ 1 day 11 hours back ∙ 51 proposals |
External report 1C 8.3 — forecast of goods balances
22 USD
An external report (.erf) is needed for 1C:Enterprise 8.3 (configuration to be specified). What it should do: Extract product balances from the database Analyze sales history for the last 30 days Calculate the average sales rate for each product Determine how many days until the… Databases & SQL, Client Management & CRM ∙ 1 day 11 hours back ∙ 11 proposals |
Web Application & Database Security Audit for Custom CRM — BaaS / Database-as-API Specialist (PenetrProject Overview We operate a custom-built customer relationship management (CRM) platform that runs two service businesses on a single system. It is a modern JavaScript web application backed by a backend-as-a-service (BaaS) database and deployed on a serverless hosting… Databases & SQL, Testing & QA ∙ 2 days back ∙ 9 proposals |
Database synchronizationSynchronization of Microsoft Access programs and CRM SalesDrive. Data transfer from CRM to Microsoft Access in the first stage (changing the funnel status). Data transfer from Microsoft Access to CRM in the second stage (changing the status in the program). Databases & SQL ∙ 2 days 6 hours back ∙ 11 proposals |
Setting up a backup system and optimizing server infrastructureObjective of the work: Ensure reliable data storage for the CRM system and application by implementing an automated backup system, as well as carry out a series of server improvements to enhance the stability, security, and performance of the infrastructure. DevOps, Databases & SQL ∙ 3 days 4 hours back ∙ 24 proposals |