DEV Community

Uzeyr OZ
Uzeyr OZ

Posted on

10 Simple Steps for SQL Performance Tuning

Database query performance plays a crucial role in determining the overall performance and efficiency of an application. Slow-running queries can lead to longer loading times and decreased user satisfaction.

In my article written to increase performance in the database, the SQL statements and table structures will be as follows, consisting of the product, curation, and viewed_products tables.

CREATE TABLE product (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(255) NOT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE curation (
  id INT AUTO_INCREMENT PRIMARY KEY,
  product_id INT NOT NULL,
  user_id INT NOT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (product_id) REFERENCES product(id)
);

CREATE TABLE `viewed_products` (
  `id` int(11) NOT NULL,
  `product_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Enter fullscreen mode Exit fullscreen mode

In the product table, the id field is the primary key and created_at field is a timestamp field that automatically updates with the current date and time. The curation table has a foreign key constraint on the product_id field, which references the id field in the product table. The user_id field in the curation table specifies which user has seen the product. The created_at field in the curation table is a timestamp field that automatically updates with the current date and time.

Importance of Database Query Performance: The performance of database queries has a significant impact on the overall performance and efficiency of an application. Slow running queries can result in longer load times and decreased user satisfaction.

Writing and Optimizing Database Queries: Writing well-optimized database queries can greatly improve performance. This involves selecting the appropriate data types, using indexes, and avoiding slow-running operations like subqueries or full table scans.

Database Indexes and Types of Indexes: Indexes are used to speed up the search process in a database. There are several types of indexes including B-tree, Hash, and Bitmap indexes. The choice of index type depends on the specific use case and query requirements.

Image description

Before adding indexes to the relevant tables in the database, I observed that the performance was 0.00261 milliseconds and I have a screen shot. I would like to show that the performance has greatly increased by adding the index, although it should be noted that the number of records is low and therefore, measurements taken here may not reflect the truth by 100%.

ALTER TABLE curation
ADD CONSTRAINT fk_curation_product_id
FOREIGN KEY (product_id)
REFERENCES product(id);

ALTER TABLE viewed_products 
ADD CONSTRAINT fk_viewed_products_product_id 
FOREIGN KEY (product_id) 
REFERENCES product(id);

Enter fullscreen mode Exit fullscreen mode

SQL statement that I used to observe the performance.

SELECT *
FROM product p
JOIN curation c ON p.id = c.product_id
WHERE p.id NOT IN (SELECT product_id FROM viewed_products WHERE user_id = 1)

Enter fullscreen mode Exit fullscreen mode

Image description

**Using Indexes for Sorting and Grouping Queries: **Indexes can be used to sort and group query results more efficiently. For example, a query that sorts by a particular column can use an index on that column to avoid a full table scan.

By creating the SQL statement into a view, it can improve performance by not retrieving data from all tables. This can help to reduce the workload on the database and improve query performance.

CREATE VIEW product_curation_view AS 
SELECT *
FROM product p
JOIN curation c ON p.id = c.product_id
WHERE p.id NOT IN (SELECT product_id FROM viewed_products WHERE user_id = 1)
order by c.id desc;
Enter fullscreen mode Exit fullscreen mode

**Impact of Database System and Server Settings: The **configuration of the database system and server can have a major impact on performance. Settings such as the buffer cache size, max connection limit, and query execution timeout can all be optimized to improve performance.

Load Testing and Monitoring Database Performance: Load testing is the process of testing an application under heavy loads to determine its performance and scalability. Monitoring database performance can help identify and resolve performance issues, such as slow running queries.

Profile Analysis and Optimization of SQL Queries: Profiling SQL queries can help identify performance bottlenecks, such as slow-running operations or missing indexes. Optimizing these issues can result in significant performance improvements.

Functional and Additional Indexes: Functional and additional indexes are used to improve the performance of specific types of queries. For example, a functional index can be created on an expression, while an additional index can be created on a computed column.

ALTER TABLE product
ADD INDEX product_created_at_idx (created_at);

ALTER TABLE curation
ADD INDEX curation_product_id_idx (product_id),
ADD INDEX curation_created_at_idx (created_at);

ALTER TABLE viewed_products
ADD INDEX viewed_products_product_id_idx (product_id),
ADD INDEX viewed_products_user_id_idx (user_id),
ADD INDEX viewed_products_created_at_idx (created_at);

Enter fullscreen mode Exit fullscreen mode

In this example, functional indexes are added to improve query performance for the created_at columns in all three tables, as well as additional indexes for the product_id and user_id columns in the curation and viewed_products tables. These indexes allow the database to quickly retrieve the data it needs, reducing the time it takes to execute a query.

Database Cache Mechanisms: Database cache mechanisms can greatly improve the performance of queries by storing frequently accessed data in memory. This can avoid the need for expensive disk I/O operations and result in faster query execution.

To set up database cache mechanisms, you can use caching technologies such as Memcached or Redis. These are in-memory data stores that cache frequently accessed data, so that the database doesn't have to retrieve the same information from disk multiple times.

Here is an example of how to set up Memcached for a MySQL database:

First, you need to install the lru-cache library:

npm install lru-cache

Enter fullscreen mode Exit fullscreen mode

Next, you need to require the library in your code and create a new cache instance:

const LRU = require('lru-cache');

const cache = new LRU({
  max: 500, // max number of items in cache
  maxAge: 1000 * 60 * 60 // 1 hour
});

Enter fullscreen mode Exit fullscreen mode

To store data in the cache, you can use the set method:

cache.set('key', 'value');

Enter fullscreen mode Exit fullscreen mode

To retrieve data from the cache, you can use the get method:

const value = cache.get('key');

Enter fullscreen mode Exit fullscreen mode

When you make a database query, you can first check if the data is in the cache. If it is, you can return the cached data. If it's not, you can query the database and store the result in the cache:

const value = cache.get('key');
if (value) {
  return value;
} else {
  // Query the database
  const result = await database.query('SELECT ...');
  cache.set('key', result);
  return result;
}


Enter fullscreen mode Exit fullscreen mode

This is a simple example of how you could use the lru-cache library to implement a cache mechanism in a Node.js application.

Continual Improvement of Database Performance: Maintaining good performance is an ongoing process, as the database and its workloads change over time. Continually monitoring and optimizing performance can ensure that the database remains efficient and performs well even as its requirements evolve.

All sql statements are below, you can use them if necessary.


-- --------------------------------------------------------

--
-- Table structure for table `curation`
--

CREATE TABLE `curation` (
  `id` int(11) NOT NULL,
  `product_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `curation`
--

INSERT INTO `curation` (`id`, `product_id`, `user_id`, `created_at`) VALUES
(1, 84, 1, '2023-02-06 05:41:00'),
(2, 102, 1, '2023-02-06 05:41:00'),
(3, 180, 1, '2023-02-06 05:41:00'),
(4, 38, 1, '2023-02-06 05:41:00'),
(5, 15, 1, '2023-02-06 05:41:00'),
(6, 117, 1, '2023-02-06 05:41:00'),
(7, 142, 1, '2023-02-06 05:41:00'),
(8, 205, 1, '2023-02-06 05:41:00'),
(9, 145, 1, '2023-02-06 05:41:00'),
(10, 189, 1, '2023-02-06 05:41:00'),
(11, 208, 1, '2023-02-06 05:41:00'),
(12, 99, 1, '2023-02-06 05:41:00'),
(13, 155, 1, '2023-02-06 05:41:00'),
(14, 173, 1, '2023-02-06 05:41:00'),
(15, 29, 1, '2023-02-06 05:41:00'),
(16, 201, 1, '2023-02-06 05:41:00'),
(17, 49, 1, '2023-02-06 05:41:00'),
(18, 196, 1, '2023-02-06 05:41:00'),
(19, 103, 1, '2023-02-06 05:41:00'),
(20, 58, 1, '2023-02-06 05:41:00'),
(21, 185, 1, '2023-02-06 05:41:00'),
(22, 123, 1, '2023-02-06 05:41:00'),
(23, 124, 1, '2023-02-06 05:41:00'),
(24, 177, 1, '2023-02-06 05:41:00'),
(25, 179, 1, '2023-02-06 05:41:00'),
(26, 34, 1, '2023-02-06 05:41:00'),
(27, 110, 1, '2023-02-06 05:41:00');

-- --------------------------------------------------------

--
-- Table structure for table `product`
--

CREATE TABLE `product` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `description` varchar(255) NOT NULL,
  `price` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `product`
--

INSERT INTO `product` (`id`, `name`, `created_at`, `description`, `price`) VALUES
(1, 'Smartphone X', '2023-02-06 05:24:28', 'This latest smartphone has a high-resolution camera and fast processor', 200),
(2, 'Laptop Y', '2023-02-06 05:24:28', 'This powerful laptop has a long battery life and large storage capacity', 1000),
(3, 'Tablet Z', '2023-02-06 05:24:28', 'This lightweight tablet is perfect for entertainment and on-the-go computing', 300),
(4, 'Headphones A', '2023-02-06 05:24:28', 'These headphones have excellent sound quality and a comfortable fit', 100),
(5, 'Speaker B', '2023-02-06 05:24:28', 'This compact speaker delivers powerful, clear sound', 80),
(6, 'Smartwatch C', '2023-02-06 05:24:28', 'This smartwatch has a variety of health and fitness tracking features', 250),
(7, 'Camera D', '2023-02-06 05:24:28', 'This high-performance camera has advanced features for professional photographers', 1500),
(8, 'Fitness Tracker E', '2023-02-06 05:24:28', 'This fitness tracker has a heart rate monitor and activity tracking features', 150),
(9, 'VR Headset F', '2023-02-06 05:24:28', 'This VR headset offers an immersive virtual reality experience', 500),
(10, 'Drone G', '2023-02-06 05:24:28', 'This drone has advanced flight control features and a high-resolution camera', 1000),
(11, 'Denim Jacket', '2023-02-06 05:26:18', 'This stylish denim jacket is made from high-quality materials', 70),
(12, 'Sweater Coat', '2023-02-06 05:26:18', 'This warm sweater coat is perfect for chilly weather', 100),
(13, 'Fashion Boots', '2023-02-06 05:26:18', 'These fashion boots are both stylish and comfortable', 150),
(14, 'Casual Shoes', '2023-02-06 05:26:18', 'These casual shoes are suitable for everyday wear', 60),
(15, 'Dress Shirt', '2023-02-06 05:26:18', 'This dress shirt is made from premium cotton and has a tailored fit', 40),
(16, 'T-Shirt', '2023-02-06 05:26:18', 'This soft T-shirt is perfect for casual outfits', 15),
(17, 'Jeans', '2023-02-06 05:26:18', 'These jeans are both comfortable and stylish', 50),
(18, 'Sneakers', '2023-02-06 05:26:18', 'These sneakers have a classic design and are suitable for casual and sports wear', 70),
(19, 'Fashion Sunglasses', '2023-02-06 05:26:18', 'These sunglasses are both stylish and offer UV protection', 30),
(20, 'Leather Bag', '2023-02-06 05:26:18', 'This high-quality leather bag is perfect for work or everyday use', 130),
(21, 'Baby Onesie', '2023-02-06 05:28:11', 'This soft and comfortable baby onesie is perfect for your little one', 10),
(22, 'Baby Romper', '2023-02-06 05:28:11', 'This cute and stylish baby romper is perfect for warm weather', 15),
(23, 'Baby Bibs', '2023-02-06 05:28:11', 'These soft and absorbent baby bibs are perfect for mealtime', 6),
(24, 'Baby Booties', '2023-02-06 05:28:11', 'These cozy baby booties will keep your little ones feet warm', 8),
(25, 'Baby Hat', '2023-02-06 05:28:11', 'This soft and warm baby hat is perfect for cold weather', 6),
(26, 'Baby Socks', '2023-02-06 05:28:11', 'These soft and comfortable baby socks are perfect for your little ones delicate skin', 4),
(27, 'Baby Swaddle', '2023-02-06 05:28:11', 'This soft and stretchy baby swaddle is perfect for keeping your little one snug and secure', 13),
(28, 'Baby Blanket', '2023-02-06 05:28:11', 'This soft and warm baby blanket is perfect for snuggling with your little one', 15),
(29, 'Baby Hooded Towel', '2023-02-06 05:28:11', 'This soft and absorbent baby hooded towel is perfect for bathtime', 13),
(30, 'Baby Washcloth Set', '2023-02-06 05:28:11', 'This set of soft and gentle baby washcloths is perfect for cleaning your little one', 7),
(31, 'Baby Onesie', '2023-02-06 05:28:17', 'This soft and comfortable baby onesie is perfect for your little one', 10),
(32, 'Baby Romper', '2023-02-06 05:28:17', 'This cute and stylish baby romper is perfect for warm weather', 15),
(33, 'Baby Bibs', '2023-02-06 05:28:17', 'These soft and absorbent baby bibs are perfect for mealtime', 6),
(34, 'Baby Booties', '2023-02-06 05:28:17', 'These cozy baby booties will keep your little ones feet warm', 8),
(35, 'Baby Hat', '2023-02-06 05:28:17', 'This soft and warm baby hat is perfect for cold weather', 6),
(36, 'Baby Socks', '2023-02-06 05:28:17', 'These soft and comfortable baby socks are perfect for your little ones delicate skin', 4),
(37, 'Baby Swaddle', '2023-02-06 05:28:17', 'This soft and stretchy baby swaddle is perfect for keeping your little one snug and secure', 13),
(38, 'Baby Blanket', '2023-02-06 05:28:17', 'This soft and warm baby blanket is perfect for snuggling with your little one', 15),
(39, 'Baby Hooded Towel', '2023-02-06 05:28:17', 'This soft and absorbent baby hooded towel is perfect for bathtime', 13),
(40, 'Baby Washcloth Set', '2023-02-06 05:28:17', 'This set of soft and gentle baby washcloths is perfect for cleaning your little one', 7),
(101, 'Smartphone X', '2023-02-06 02:24:28', 'This latest smartphone has a high-resolution camera and fast processor', 200),
(102, 'Laptop Y', '2023-02-06 02:24:28', 'This powerful laptop has a long battery life and large storage capacity', 1000),
(103, 'Tablet Z', '2023-02-06 02:24:28', 'This lightweight tablet is perfect for entertainment and on-the-go computing', 300),
(104, 'Headphones A', '2023-02-06 02:24:28', 'These headphones have excellent sound quality and a comfortable fit', 100),
(105, 'Speaker B', '2023-02-06 02:24:28', 'This compact speaker delivers powerful, clear sound', 80),
(106, 'Smartwatch C', '2023-02-06 02:24:28', 'This smartwatch has a variety of health and fitness tracking features', 250),
(107, 'Camera D', '2023-02-06 02:24:28', 'This high-performance camera has advanced features for professional photographers', 1500),
(108, 'Fitness Tracker E', '2023-02-06 02:24:28', 'This fitness tracker has a heart rate monitor and activity tracking features', 150),
(109, 'VR Headset F', '2023-02-06 02:24:28', 'This VR headset offers an immersive virtual reality experience', 500),
(110, 'Drone G', '2023-02-06 02:24:28', 'This drone has advanced flight control features and a high-resolution camera', 1000),
(111, 'Denim Jacket', '2023-02-06 02:26:18', 'This stylish denim jacket is made from high-quality materials', 70),
(112, 'Sweater Coat', '2023-02-06 02:26:18', 'This warm sweater coat is perfect for chilly weather', 100),
(113, 'Fashion Boots', '2023-02-06 02:26:18', 'These fashion boots are both stylish and comfortable', 150),
(114, 'Casual Shoes', '2023-02-06 02:26:18', 'These casual shoes are suitable for everyday wear', 60),
(115, 'Dress Shirt', '2023-02-06 02:26:18', 'This dress shirt is made from premium cotton and has a tailored fit', 40),
(116, 'T-Shirt', '2023-02-06 02:26:18', 'This soft T-shirt is perfect for casual outfits', 15),
(117, 'Jeans', '2023-02-06 02:26:18', 'These jeans are both comfortable and stylish', 50),
(118, 'Sneakers', '2023-02-06 02:26:18', 'These sneakers have a classic design and are suitable for casual and sports wear', 70),
(119, 'Fashion Sunglasses', '2023-02-06 02:26:18', 'These sunglasses are both stylish and offer UV protection', 30),
(120, 'Leather Bag', '2023-02-06 02:26:18', 'This high-quality leather bag is perfect for work or everyday use', 130),
(121, 'Baby Onesie', '2023-02-06 02:28:11', 'This soft and comfortable baby onesie is perfect for your little one', 10),
(122, 'Baby Romper', '2023-02-06 02:28:11', 'This cute and stylish baby romper is perfect for warm weather', 15),
(123, 'Baby Bibs', '2023-02-06 02:28:11', 'These soft and absorbent baby bibs are perfect for mealtime', 6),
(124, 'Baby Booties', '2023-02-06 02:28:11', 'These cozy baby booties will keep your little ones feet warm', 8),
(125, 'Baby Hat', '2023-02-06 02:28:11', 'This soft and warm baby hat is perfect for cold weather', 6),
(126, 'Baby Socks', '2023-02-06 02:28:11', 'These soft and comfortable baby socks are perfect for your little ones delicate skin', 4),
(127, 'Baby Swaddle', '2023-02-06 02:28:11', 'This soft and stretchy baby swaddle is perfect for keeping your little one snug and secure', 13),
(128, 'Baby Blanket', '2023-02-06 02:28:11', 'This soft and warm baby blanket is perfect for snuggling with your little one', 15),
(129, 'Baby Hooded Towel', '2023-02-06 02:28:11', 'This soft and absorbent baby hooded towel is perfect for bathtime', 13),
(130, 'Baby Washcloth Set', '2023-02-06 02:28:11', 'This set of soft and gentle baby washcloths is perfect for cleaning your little one', 7),
(131, 'Baby Onesie', '2023-02-06 02:28:17', 'This soft and comfortable baby onesie is perfect for your little one', 10),
(132, 'Baby Romper', '2023-02-06 02:28:17', 'This cute and stylish baby romper is perfect for warm weather', 15),
(133, 'Baby Bibs', '2023-02-06 02:28:17', 'These soft and absorbent baby bibs are perfect for mealtime', 6),
(134, 'Baby Booties', '2023-02-06 02:28:17', 'These cozy baby booties will keep your little ones feet warm', 8),
(135, 'Baby Hat', '2023-02-06 02:28:17', 'This soft and warm baby hat is perfect for cold weather', 6),
(136, 'Baby Socks', '2023-02-06 02:28:17', 'These soft and comfortable baby socks are perfect for your little ones delicate skin', 4),
(137, 'Baby Swaddle', '2023-02-06 02:28:17', 'This soft and stretchy baby swaddle is perfect for keeping your little one snug and secure', 13),
(138, 'Baby Blanket', '2023-02-06 02:28:17', 'This soft and warm baby blanket is perfect for snuggling with your little one', 15),
(139, 'Baby Hooded Towel', '2023-02-06 02:28:17', 'This soft and absorbent baby hooded towel is perfect for bathtime', 13),
(140, 'Baby Washcloth Set', '2023-02-06 02:28:17', 'This set of soft and gentle baby washcloths is perfect for cleaning your little one', 7),
(141, 'Baby Onesie', '2023-02-06 05:31:18', 'This soft and comfortable baby onesie is perfect for your little one.', 10),
(142, 'Baby Romper', '2023-02-06 05:31:18', 'This cute and stylish baby romper is perfect for warm weather.', 15),
(143, 'Baby Bibs', '2023-02-06 05:31:18', 'These soft and absorbent baby bibs are perfect for mealtime.', 6),
(144, 'Baby Booties', '2023-02-06 05:31:18', 'These cozy baby booties will keep your little ones feet warm.', 8),
(145, 'Baby Hat', '2023-02-06 05:31:18', 'This soft and warm baby hat is perfect for cold weather.', 6),
(146, 'Baby Socks', '2023-02-06 05:31:18', 'These soft and comfortable baby socks are perfect for your little ones delicate skin.', 4),
(147, 'Baby Swaddle', '2023-02-06 05:31:18', 'This soft and stretchy baby swaddle is perfect for keeping your little one snug and secure.', 13),
(148, 'Baby Blanket', '2023-02-06 05:31:18', 'This soft and warm baby blanket is perfect for snuggling with your little one.', 15),
(149, 'Baby Hooded Towel', '2023-02-06 05:31:18', 'This soft and absorbent baby hooded towel is perfect for bathtime.', 13),
(150, 'Baby Washcloth Set', '2023-02-06 05:31:18', 'This set of soft and gentle baby washcloths is perfect for cleaning your little one.', 7),
(151, 'Cotton Onesie', '2023-02-06 05:31:18', 'This soft and comfortable cotton onesie is perfect for your little one.', 10),
(152, 'Cotton Romper', '2023-02-06 05:31:18', 'This cute and stylish cotton romper is perfect for warm weather.', 15),
(153, 'Cotton Bibs', '2023-02-06 05:31:18', 'These soft and absorbent cotton bibs are perfect for mealtime.', 6),
(154, 'Cotton Booties', '2023-02-06 05:31:18', 'These cozy cotton booties will keep your little ones feet warm.', 8),
(155, 'Cotton Hat', '2023-02-06 05:31:18', 'This soft and warm cotton hat is perfect for cold weather.', 6),
(156, 'Cotton Socks', '2023-02-06 05:31:18', 'These soft and comfortable cotton socks are perfect for your little one delicate skin.', 4),
(157, 'Cotton Swaddle', '2023-02-06 05:31:18', 'This soft and stretchy cotton swaddle is perfect for keeping your little one snug and secure.', 13),
(158, 'Cotton Blanket', '2023-02-06 05:31:18', 'This soft and warm cotton blanket is perfect for snuggling with your little one.', 15),
(159, 'Cotton Hooded Towel', '2023-02-06 05:31:18', 'This soft and absorbent cotton hooded towel is perfect for bathtime.', 13),
(160, 'Cotton Washcloth Set', '2023-02-06 05:31:18', 'This set of soft and gentle cotton washcloths is perfect for cleaning your little one.', 7),
(161, 'Baby Onesie', '2023-02-06 05:31:22', 'This soft and comfortable baby onesie is perfect for your little one.', 10),
(162, 'Baby Romper', '2023-02-06 05:31:22', 'This cute and stylish baby romper is perfect for warm weather.', 15),
(163, 'Baby Bibs', '2023-02-06 05:31:22', 'These soft and absorbent baby bibs are perfect for mealtime.', 6),
(164, 'Baby Booties', '2023-02-06 05:31:22', 'These cozy baby booties will keep your little ones feet warm.', 8),
(165, 'Baby Hat', '2023-02-06 05:31:22', 'This soft and warm baby hat is perfect for cold weather.', 6),
(166, 'Baby Socks', '2023-02-06 05:31:22', 'These soft and comfortable baby socks are perfect for your little ones delicate skin.', 4),
(167, 'Baby Swaddle', '2023-02-06 05:31:22', 'This soft and stretchy baby swaddle is perfect for keeping your little one snug and secure.', 13),
(168, 'Baby Blanket', '2023-02-06 05:31:22', 'This soft and warm baby blanket is perfect for snuggling with your little one.', 15),
(169, 'Baby Hooded Towel', '2023-02-06 05:31:22', 'This soft and absorbent baby hooded towel is perfect for bathtime.', 13),
(170, 'Baby Washcloth Set', '2023-02-06 05:31:22', 'This set of soft and gentle baby washcloths is perfect for cleaning your little one.', 7),
(171, 'Cotton Onesie', '2023-02-06 05:31:22', 'This soft and comfortable cotton onesie is perfect for your little one.', 10),
(172, 'Cotton Romper', '2023-02-06 05:31:22', 'This cute and stylish cotton romper is perfect for warm weather.', 15),
(173, 'Cotton Bibs', '2023-02-06 05:31:22', 'These soft and absorbent cotton bibs are perfect for mealtime.', 6),
(174, 'Cotton Booties', '2023-02-06 05:31:22', 'These cozy cotton booties will keep your little ones feet warm.', 8),
(175, 'Cotton Hat', '2023-02-06 05:31:22', 'This soft and warm cotton hat is perfect for cold weather.', 6),
(176, 'Cotton Socks', '2023-02-06 05:31:22', 'These soft and comfortable cotton socks are perfect for your little one delicate skin.', 4),
(177, 'Cotton Swaddle', '2023-02-06 05:31:22', 'This soft and stretchy cotton swaddle is perfect for keeping your little one snug and secure.', 13),
(178, 'Cotton Blanket', '2023-02-06 05:31:22', 'This soft and warm cotton blanket is perfect for snuggling with your little one.', 15),
(179, 'Cotton Hooded Towel', '2023-02-06 05:31:22', 'This soft and absorbent cotton hooded towel is perfect for bathtime.', 13),
(180, 'Cotton Washcloth Set', '2023-02-06 05:31:22', 'This set of soft and gentle cotton washcloths is perfect for cleaning your little one.', 7),
(181, 'Soft and comfortable baby bodysuit yellow', '2023-02-06 05:35:00', 'This baby bodysuit is made of soft and comfortable material', 36),
(182, 'Adorable baby romper with cute pattern yellow', '2023-02-06 05:35:00', 'This baby romper features a cute pattern that is sure to delight', 48),
(183, 'Striped baby jumpsuit yellow', '2023-02-06 05:35:00', 'This striped baby jumpsuit is both stylish and practical', 34),
(184, 'Cute and cozy baby onesie yellow', '2023-02-06 05:35:00', 'This baby onesie is both cute and cozy, perfect for keeping your little one warm', 25),
(185, 'Trendy baby hoodie yellow', '2023-02-06 05:35:00', 'This baby hoodie is both trendy and practical, perfect for keeping your little one warm', 24),
(186, 'Soft baby blanket yellow', '2023-02-06 05:35:00', 'This soft baby blanket is perfect for keeping your little one warm and comfortable', 47),
(187, 'Stylish baby bib yellow', '2023-02-06 05:35:00', 'This stylish baby bib is both functional and trendy, perfect for mealtime', 62),
(188, 'Cute baby booties yellow', '2023-02-06 05:35:00', 'These cute baby booties will keep your little one\'s feet warm and stylish', 70),
(189, 'Comfortable baby hat yellow', '2023-02-06 05:35:00', 'This comfortable baby hat is perfect for keeping your little one warm on chilly days', 66),
(190, 'Stylish baby gloves yellow', '2023-02-06 05:35:00', 'These stylish baby gloves will keep your little one\'s hands warm and looking great', 18),
(191, 'Trendy baby socks yellow', '2023-02-06 05:35:00', 'These trendy baby socks are both stylish and practical', 92),
(192, 'Cozy baby leggings yellow', '2023-02-06 05:35:00', 'These cozy baby leggings are perfect for keeping your little one warm and comfortable', 7),
(193, 'Cute baby t-shirt yellow', '2023-02-06 05:35:00', 'This cute baby t-shirt is perfect for keeping your little one cool and comfortable', 58),
(194, 'Comfortable baby pants yellow', '2023-02-06 05:35:00', 'These comfortable baby pants are perfect for keeping your little one cool and cozy', 71),
(195, 'Stylish baby dress yellow', '2023-02-06 05:35:00', 'This stylish baby dress is perfect for special occasions', 82),
(196, 'Cute baby skirt yellow', '2023-02-06 05:35:00', 'This cute baby skirt is perfect for keeping your little one stylish and comfortable', 96),
(197, 'Comfortable baby shorts yellow', '2023-02-06 05:35:00', 'These comfortable baby shorts are perfect for keeping your little one cool and comfortable', 33),
(198, 'Stylish baby sweater yellow', '2023-02-06 05:35:00', 'This stylish baby sweater is perfect for keeping your little one warm and looking great', 81),
(199, 'Cute baby hat yellow', '2023-02-06 05:35:00', 'This cute baby hat is both stylish and practical, perfect for keeping your little one warm', 6),
(200, 'Comfortable baby jacket yellow', '2023-02-06 05:35:00', 'This comfortable baby jacket is perfect for keeping your little one warm and cozy on chilly days', 86),
(201, 'Soft and comfortable baby bodysuit yellow', '2023-02-06 05:35:08', 'This baby bodysuit is made of soft and comfortable material', 15),
(202, 'Adorable baby romper with cute pattern yellow', '2023-02-06 05:35:08', 'This baby romper features a cute pattern that is sure to delight', 38),
(203, 'Striped baby jumpsuit yellow', '2023-02-06 05:35:08', 'This striped baby jumpsuit is both stylish and practical', 46),
(204, 'Cute and cozy baby onesie yellow', '2023-02-06 05:35:08', 'This baby onesie is both cute and cozy, perfect for keeping your little one warm', 16),
(205, 'Trendy baby hoodie yellow', '2023-02-06 05:35:08', 'This baby hoodie is both trendy and practical, perfect for keeping your little one warm', 45),
(206, 'Soft baby blanket yellow', '2023-02-06 05:35:08', 'This soft baby blanket is perfect for keeping your little one warm and comfortable', 75),
(207, 'Stylish baby bib yellow', '2023-02-06 05:35:08', 'This stylish baby bib is both functional and trendy, perfect for mealtime', 40),
(208, 'Cute baby booties yellow', '2023-02-06 05:35:08', 'These cute baby booties will keep your little one\'s feet warm and stylish', 75),
(209, 'Comfortable baby hat yellow', '2023-02-06 05:35:08', 'This comfortable baby hat is perfect for keeping your little one warm on chilly days', 55),
(210, 'Stylish baby gloves yellow', '2023-02-06 05:35:08', 'These stylish baby gloves will keep your little one\'s hands warm and looking great', 50),
(211, 'Trendy baby socks yellow', '2023-02-06 05:35:08', 'These trendy baby socks are both stylish and practical', 88),
(212, 'Cozy baby leggings yellow', '2023-02-06 05:35:08', 'These cozy baby leggings are perfect for keeping your little one warm and comfortable', 91),
(213, 'Cute baby t-shirt yellow', '2023-02-06 05:35:08', 'This cute baby t-shirt is perfect for keeping your little one cool and comfortable', 90),
(214, 'Comfortable baby pants yellow', '2023-02-06 05:35:08', 'These comfortable baby pants are perfect for keeping your little one cool and cozy', 77),
(215, 'Stylish baby dress yellow', '2023-02-06 05:35:08', 'This stylish baby dress is perfect for special occasions', 17),
(216, 'Cute baby skirt yellow', '2023-02-06 05:35:08', 'This cute baby skirt is perfect for keeping your little one stylish and comfortable', 54),
(217, 'Comfortable baby shorts yellow', '2023-02-06 05:35:08', 'These comfortable baby shorts are perfect for keeping your little one cool and comfortable', 18),
(218, 'Stylish baby sweater yellow', '2023-02-06 05:35:08', 'This stylish baby sweater is perfect for keeping your little one warm and looking great', 28),
(219, 'Cute baby hat yellow', '2023-02-06 05:35:08', 'This cute baby hat is both stylish and practical, perfect for keeping your little one warm', 86),
(220, 'Comfortable baby jacket yellow', '2023-02-06 05:35:08', 'This comfortable baby jacket is perfect for keeping your little one warm and cozy on chilly days', 47),
(221, 'Soft and comfortable baby bodysuit yellow', '2023-02-06 05:35:12', 'This baby bodysuit is made of soft and comfortable material', 9),
(222, 'Adorable baby romper with cute pattern yellow', '2023-02-06 05:35:12', 'This baby romper features a cute pattern that is sure to delight', 25),
(223, 'Striped baby jumpsuit yellow', '2023-02-06 05:35:12', 'This striped baby jumpsuit is both stylish and practical', 98),
(224, 'Cute and cozy baby onesie yellow', '2023-02-06 05:35:12', 'This baby onesie is both cute and cozy, perfect for keeping your little one warm', 15),
(225, 'Trendy baby hoodie yellow', '2023-02-06 05:35:12', 'This baby hoodie is both trendy and practical, perfect for keeping your little one warm', 83),
(226, 'Soft baby blanket yellow', '2023-02-06 05:35:12', 'This soft baby blanket is perfect for keeping your little one warm and comfortable', 67),
(227, 'Stylish baby bib yellow', '2023-02-06 05:35:12', 'This stylish baby bib is both functional and trendy, perfect for mealtime', 90),
(228, 'Cute baby booties yellow', '2023-02-06 05:35:12', 'These cute baby booties will keep your little one\'s feet warm and stylish', 47),
(229, 'Comfortable baby hat yellow', '2023-02-06 05:35:12', 'This comfortable baby hat is perfect for keeping your little one warm on chilly days', 66),
(230, 'Stylish baby gloves yellow', '2023-02-06 05:35:12', 'These stylish baby gloves will keep your little one\'s hands warm and looking great', 89),
(231, 'Trendy baby socks yellow', '2023-02-06 05:35:12', 'These trendy baby socks are both stylish and practical', 46),
(232, 'Cozy baby leggings yellow', '2023-02-06 05:35:12', 'These cozy baby leggings are perfect for keeping your little one warm and comfortable', 65),
(233, 'Cute baby t-shirt yellow', '2023-02-06 05:35:12', 'This cute baby t-shirt is perfect for keeping your little one cool and comfortable', 88),
(234, 'Comfortable baby pants yellow', '2023-02-06 05:35:12', 'These comfortable baby pants are perfect for keeping your little one cool and cozy', 47),
(235, 'Stylish baby dress yellow', '2023-02-06 05:35:12', 'This stylish baby dress is perfect for special occasions', 69),
(236, 'Cute baby skirt yellow', '2023-02-06 05:35:12', 'This cute baby skirt is perfect for keeping your little one stylish and comfortable', 6),
(237, 'Comfortable baby shorts yellow', '2023-02-06 05:35:12', 'These comfortable baby shorts are perfect for keeping your little one cool and comfortable', 23),
(238, 'Stylish baby sweater yellow', '2023-02-06 05:35:12', 'This stylish baby sweater is perfect for keeping your little one warm and looking great', 97),
(239, 'Cute baby hat yellow', '2023-02-06 05:35:12', 'This cute baby hat is both stylish and practical, perfect for keeping your little one warm', 19),
(240, 'Comfortable baby jacket yellow', '2023-02-06 05:35:12', 'This comfortable baby jacket is perfect for keeping your little one warm and cozy on chilly days', 2);

-- --------------------------------------------------------

--
-- Table structure for table `viewed_products`
--

CREATE TABLE `viewed_products` (
  `id` int(11) NOT NULL,
  `product_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `viewed_products`
--

INSERT INTO `viewed_products` (`id`, `product_id`, `user_id`, `created_at`) VALUES
(1, 164, 1, '2023-02-06 05:42:29'),
(2, 88, 1, '2023-02-06 05:42:29'),
(3, 167, 1, '2023-02-06 05:42:29'),
(4, 136, 1, '2023-02-06 05:42:29'),
(5, 178, 1, '2023-02-06 05:42:29'),
(6, 52, 1, '2023-02-06 05:42:29'),
(7, 155, 1, '2023-02-06 05:42:29'),
(8, 187, 1, '2023-02-06 05:42:29'),
(9, 36, 1, '2023-02-06 05:42:29'),
(10, 51, 1, '2023-02-06 05:42:29'),
(11, 148, 1, '2023-02-06 05:42:29'),
(12, 23, 1, '2023-02-06 05:42:33'),
(13, 18, 1, '2023-02-06 05:42:33'),
(14, 18, 1, '2023-02-06 05:42:33'),
(15, 36, 1, '2023-02-06 05:42:33'),
(16, 126, 1, '2023-02-06 05:42:33'),
(17, 90, 1, '2023-02-06 05:42:33'),
(18, 70, 1, '2023-02-06 05:42:33'),
(19, 80, 1, '2023-02-06 05:42:33'),
(20, 191, 1, '2023-02-06 05:42:33'),
(21, 67, 1, '2023-02-06 05:42:33'),
(22, 194, 1, '2023-02-06 05:42:33'),
(23, 89, 1, '2023-02-06 05:42:36'),
(24, 214, 1, '2023-02-06 05:42:36'),
(25, 154, 1, '2023-02-06 05:42:36'),
(26, 127, 1, '2023-02-06 05:42:36'),
(27, 173, 1, '2023-02-06 05:42:36'),
(28, 52, 1, '2023-02-06 05:42:36'),
(29, 172, 1, '2023-02-06 05:42:36'),
(30, 54, 1, '2023-02-06 05:42:36'),
(31, 188, 1, '2023-02-06 05:42:36'),
(32, 127, 1, '2023-02-06 05:42:36'),
(33, 72, 1, '2023-02-06 05:42:36');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `curation`
--
ALTER TABLE `curation`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_curation_product_id` (`product_id`);

--
-- Indexes for table `product`
--
ALTER TABLE `product`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `viewed_products`
--
ALTER TABLE `viewed_products`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_viewed_products_product_id` (`product_id`);

Enter fullscreen mode Exit fullscreen mode

Top comments (0)