How to optimize this subquery (without using Select inside Where clause)?

Advertisements I am trying to see if there is a way to optimize bottom T-SQL code. This is how previous co-worker wrote, and I am not sure if there is a better way to write because it has Select… within Where clause (subquery?). select Employee_Number, DateLoad from dbo.table1 as a where DateLoad = (select min(DateLoad)… Read More How to optimize this subquery (without using Select inside Where clause)?

can anyone help me to optimize the where clause

Advertisements i have a below query it using index but not yet optimized I don’t know what is the problem can anyone help me with this ? select date(mfd.MFD_FITMENT_DATE) as MFD_FITMENT_DATE, count(*) cnt_fitment FROM MMHSRP_FITMENT_DATE mfd, CUSTOMER_REGISTRATION_DETAILS crd, EMBOSSING_STATION_MAPPING_DETAILS esmd where mfd.MFD_CRD_ID = crd.CRD_ID AND esmd.ESMD_SDM_ID = crd.CRD_SDM_ID AND esmd.ESMD_ESM_ID = ‘9’ AND mfd.MFD_STATUS =… Read More can anyone help me to optimize the where clause

MYSQL delete from large table increase the delete time for each transaction

Advertisements I am trying to delete data from table which contains almost 6,000,000,000 records , with where clause. here is the stored procedure I am using and running from command prompt MySQL in windows. DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `clean_table`( ) BEGIN REPEAT DO SLEEP(1); DELETE FROM tablename WHERE exportInfoId<=8479 limit 100000; SELECT ROW_COUNT(); UNTIL… Read More MYSQL delete from large table increase the delete time for each transaction

How to get a single record per group from one day ago in a very large MySQL table?

Advertisements Suppose I have a table containing various types of fruit and vegetables. Once every 5-10 minutes, I am checking the current price of all items I have listed, and I insert a new record for that timestamp with the current price. The following is an example of such a table (number of rows reduced… Read More How to get a single record per group from one day ago in a very large MySQL table?

Calculating totals and percentages for each row, in a time boxed window, for a relation

Advertisements Ok, so I’ve got two tables: jobs, and job runs. I’m using Postgres. I want to look at 2 periods. 7 days ago until now, and 14 days ago to 7 days ago. For each job, I want a total of the number of runs, and a percentage of successful and unsuccessful runs for… Read More Calculating totals and percentages for each row, in a time boxed window, for a relation