问题描述
嗨frenz,我有一个问题是从表中缓慢加载不同的列值。我知道从数据库加载数据的替代方法要快得多。下面的查询需要1分半钟才能获取数据。请建议正确的方法。谢谢。
我尝试了什么:
SET @ t1 = CONCAT('SELECT DISTINCT gender FROM',tablename);
SET @ t2 = CONCAT('SELECT DISTINCT country FROM',tablename);
SET @ t3 = CONCAT ('SELECT DISTINCT DATE_FORMAT(date_time,\'%Y-%m-%d \')as date_time FROM',tablename,'where source =','\'',sourceslist,'\'') ;
SET @ t4 = CONCAT('SELECT DISTINCT product_name FROM',tablename);
SET @ t5 = CONCAT('SELECT DISTINCT source FROM',tablename);
这里表名采用包含的动态名称超过3800000行
Hi frenz, I have a problem of slow loading of distinct column values from table.Can i know the alternative way to load the data from database much faster. The query below is taking 1 and half minute to fetch data. Please suggest the right way. Thank you.
What I have tried:
SET @t1 = CONCAT('SELECT DISTINCT gender FROM ', tablename);
SET @t2 = CONCAT('SELECT DISTINCT country FROM ',tablename);
SET @t3 = CONCAT('SELECT DISTINCT DATE_FORMAT(date_time,\'%Y-%m-%d\') as date_time FROM ', tablename,' where source=','\'',sourceslist, '\'');
SET @t4 = CONCAT('SELECT DISTINCT product_name FROM ', tablename);
SET @t5 = CONCAT('SELECT DISTINCT source FROM ', tablename);
here table name takes the dynamic name which is containing more than 3800000 rows
推荐答案
这篇关于如何在从mysql表中获取不同的列值时加快查询执行速度。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!