CodeGym /Courses /SQL SELF /Running Scheduled Tasks

Running Scheduled Tasks

SQL SELF
Level 61 , Lesson 4
Available

If you've already done literally everything, I honestly don't even know what else to suggest for you...

Businesses often need to generate different reports on a schedule. Daily, weekly, monthly, and every quarter. I think you could totally automate these tasks too, if you wanted to :)

Creating Scheduled Reports

Below are some ideas for expanding the list of reports that should be generated regularly or periodically as part of a marketplace's operations. Each report comes with a reason: why it's needed, what value it brings to the business, what decisions you can make based on it, or what processes you can optimize. I recommend you think about automating the creation of these reports on a schedule.

1. User Base Growth and Structure Dynamics Report

Understanding user growth, their activity, demographics, and structure (new vs. returning, regions, acquisition channels) is critical for scaling, marketing, and evaluating how effective your promotion channels are. This report helps you spot ineffective traffic sources, track how well marketing campaigns are working, and manage user segments for personalized offers.

2. Sales Funnel Conversion Report

Analyzing the funnel—from the first site visit to purchase—gives you insight into the "weak spots" in the order process. With this report, you can find bottlenecks where users drop off (like leaving at payment, registration, or taking too long to pick delivery), and make targeted UX improvements. It's also used to evaluate A/B tests and new features.

3. Logistics and Delivery Delays & SLA Report

Good logistics are a marketplace's competitive edge. A regular report on average assembly speed, delivery time, share of overdue orders, and reasons for delays lets you keep service metrics in check, optimize routes, and spot problematic logistics partners or regions that need extra attention.

4. Assortment and Category Effectiveness Report

This lets you analyze sales by category, brand, and product segment, spot "locomotives" and "dead zones" in your catalog, and manage assortment, promos, and rearticulation in time. Metrics include: revenue by category, out-of-stock share, average storage time for products in the warehouse, conversion to purchase by category.

5. Return and Order Cancellation Reasons Analysis

Diving deep into returns and cancellations helps you fight real business problems: bad products, description errors, delivery issues, payment troubles. The report aggregates reasons for returns/cancellations, trends, repeat returners share, which helps you make decisions to improve product quality, train sellers, or work with logistics.

6. Monthly P&L Reporting: Revenue, Margin, Returns

Financial transparency is key for sustainable growth. The P&L report includes revenue, returns, write-offs, cost of goods sold, margin, ad and logistics expenses. It helps you track profitability, quickly spot unprofitable areas, plan budgets, and justify investments.

7. Ad Campaign, Discount, and Promo Code Effectiveness Report

This lets you really see: which campaigns and discounts actually drive sales, and which just cut margin without boosting turnover. Includes share of orders with promo codes and discounts, revenue from each promo, average check, repeat purchases after promos, campaign ROI. Super useful for optimizing marketing budgets and targeting.

8. Customer Support Performance Report (SLA, Quality, Satisfaction)

Tracks support load, average first response time, share of requests by question category, user satisfaction level (NPS/ticket rating), share of tickets closed on time per SLA. This helps plan operator workload, find service growth points, and reduce load by building out a knowledge base.

9. Most Problematic Products and Suppliers Report

Analyzes products/suppliers with the most returns, complaints, bad ratings, or supply issues. This report helps you spot "risky" items that need to be either removed from the catalog, urgently discussed with the supplier, or checked extra carefully in the warehouse.

10. Security and Admin Activity Audit Report

Keeps track of admin actions (creating/deleting products, changing prices, managing promo codes and discounts, changing order statuses), as well as login logs and failed access attempts. Lets you spot suspicious activity, prevent or investigate fraud, and meet internal and external audit requirements.

11. User Engagement and Retention Report

Analyzes repeat visits, customer returns, cohorts, retention trends by day/week, and the impact of promos and site changes on engagement. Lets you build loyalty strategies, evaluate the effect of personalization and UI tweaks.

12. Popular Search Queries and Failed Searches Report

This report reveals what buyers are interested in, what products they're searching for but not finding, and demand trends. Useful for assortment planning, search optimization, and adding autocomplete/SEO. Analyzes query frequency, share of empty searches, search-to-purchase conversion.

13. Data Quality and Directory Integrity Report

Helps you spot duplicate/invalid categories, products without photos, incomplete cards, unlinked SKUs, incorrect statuses, errors in required fields. This helps keep your catalog high-quality, do cleanups, and maintain a pro-level content standard.

14. Practice: Warehouse Stock Usage Reports

Includes periodic reports on stock movement, number of auto-orders, fast-moving/slow-moving products, warehouse space usage efficiency. This report is a must for logistics and purchasing to plan supplies and minimize warehouse stock.

15. Content Marketing Effectiveness Report (Articles/News)

Analyzes audience engagement with articles, view time, transitions from content to catalog, top topics and authors, impact of publications on sales. Helps optimize your content marketing strategy, boost organic traffic, and keep users coming back.

Setting Up Scheduled Backups

Below is a list of backup types you should regularly set up for a complex marketplace database with 100+ tables, with detailed reasoning for each case. This approach gives you high reliability, fast data recovery, and keeps business-critical processes resilient.

1. Full Regular Backup of the Entire Database

Full backup is the foundation of data protection strategies. In case of major failures (hardware crash, attack on the whole DB, serious admin mistake, mass file corruption, etc.), only a full dump lets you restore the service to any point in time from the latest saved data. With lots of interconnected tables and complex links, partial backups can't replace a full snapshot of the whole DB. It's recommended to do nightly backups and keep several rotations.

2. Incremental Backups (WAL Archiving/Point-in-Time Recovery)

For big, fast-changing marketplaces, it's crucial to restore data "down to the minute" between full backups. Incremental backups (WAL log archiving) let you "roll back" the DB to a moment before an accidental delete, crash, virus attack, or other unexpected error, even if the failure happened between two full backups. This also minimizes data loss in emergencies. It's recommended to keep WAL archives for at least a week.

3. User Data and Profile Backup ("user" schema)

User profiles, passwords, emails, login history, settings—losing this data directly affects account access, trust, and business. A dedicated regular backup of the "user" schema protects against accidental changes in this module (like mass deletion, migration error), and also speeds up partial recovery without touching the rest of the data.

Especially valuable during mass registrations or user compromise incidents.

4. Orders, Carts, and Payments Backup ("order" and "payment" schema)

Order, payment, and return data is the core of accounting, support, and the platform. Losing it means financial losses, legal disputes, and no user support. A dedicated backup of these schemas protects transaction history, lets you quickly restore orders and payments after targeted failures or staff mistakes (like accidental mass order cancellation or payment import crash).

5. Hourly Backups of Key Directories and Product Catalog ("product" schema and ref)

Product catalog, attributes, categories, and directories (countries, currencies, statuses) are the foundation of site visibility and correct operation. Staff mistakes (like wrong mass upload/edit of the catalog) can damage or wipe data, making the catalog unusable and blocking orders. Higher frequency (like every hour) lets you restore the product showcase and admin activity as fast as possible.

6. Admin Action History and Audit Log Backup (admin.audit_log)

Admin actions (audit_log) are the basis for internal investigations, control, tracking incident causes, and protection from insider abuse. It's critical that this history is available even if the DB crashes: for example, if an admin tries to maliciously delete traces of their actions. It's recommended to store audit_log backups on a separate secure server.

7. Customer Support and SLA Backup ("support" schema)

Support tickets, ticket conversations, SLA—all this affects service quality and the marketplace's legal protection. If you lose this data, you can't prove you met or broke obligations to clients, restore communication history, or resolve incidents. A separate backup of the support schema lets you quickly restore reputation-critical data (even if the main archive isn't good for fast selection).

8. Analytics and Activity Log Backup (analytics.*)

Analytics data (views, search queries, conversions, A/B tests) is used for strategic and tactical decisions—marketing, SEO, new feature development. Losing this data won't stop the platform, but you'll lose competitive advantages and historical trends. Backing up this module less often (like once a day) saves resources but protects valuable insights.

9. Content Data and CMS Backup (content.*)

Content is texts, pages, articles, banners, media files, navigation. Losing it means your site's unique content (SEO, marketing articles, promo pages) disappears, which hurts indexing, traffic, and user trust. It's recommended to back up the content schema separately, so you can restore specific content without touching the rest of the structure.

10. Restore Test Checks and Automated Recovery

Just backing up doesn't guarantee anything—you have to do regular (like weekly or monthly) restore tests on a separate environment. This lets you spot broken backups, automation errors, version mismatches, and also see the real platform recovery time. This practice is an industry standard to prevent disasters and be sure your data is actually protected.

Congrats

These backups cover all the key data loss risks for a full-on e-commerce marketplace and make it possible to restore any or all business-critical processes.

Congrats. If you managed to complete all the tasks in the final project, you totally nailed working with databases 10/10

You’re just awesome. See you in the NoSQL course :)

Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION