<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"><channel><category>pcsoft.us.windev</category><copyright>Copyright 2026, PC SOFT</copyright><lastBuildDate>5 Aug 2016 03:23:23 Z</lastBuildDate><pubDate>2 Aug 2016 01:28:00 Z</pubDate><description>Hi&#13;
We have a SQL query which is built up from user entered selections but is essentially as follows:SELECT h.RegisterId, h.ShiftNum,h.userid,h.Date as ShiftDate, sum(LineValue) As Value, SUM(d.DiscountValue) AS DiscountValue FROM saldet d INNER JOIN salhead h ON (d.salhead_linkid = h.sysid) WHERE h.branchId = 'DE' AND h.RegisterID &gt;= '01' AND h.RegisterId &lt;= '01' GROUP BY RegisterId, ShiftNum,ShiftDate,userid The query works fine if we have RegisterId = '01' but as soon as we try a range of registers (either as above or using BETWEEN) it just dies. Looking at the Explain feature in HFSQL Control Centre I can see that it uses an index when RegisterId='01' but not for a range of registers. We have some other selection options which allow for selection of range of dates and shift numbers &amp; these work fine, an index is always selected, unless we include a range of registers.&#13;
&#13;
We have a number of indexes set on Salhead file, the pertinent ones being:&#13;
BranchId, RegisterId, TranType, Reference&#13;
BranchId, RegisterId, ShiftNum, Date, Reference&#13;
BranchId, Date, RegisterId&#13;
&#13;
The question is, why doesn't it use one of these indexes &amp; is there a way I can force it to do so?&#13;
&#13;
Thanks&#13;
&#13;
David</description><ttl>30</ttl><generator>WEBDEV</generator><language>en_US</language><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql/read.awp</link><title>Slow Running SQL Query (HFSQL)</title><managingEditor>moderateur@pcsoft.fr (El moderador)</managingEditor><webMaster>webmaster@pcsoft.fr (El webmaster)</webMaster><item><author>CCordes</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58971/read.awp</comments><pubDate>5 Aug 2016 03:23:23 Z</pubDate><description>Hi David,&#13;
&#13;
There are a LOT of ways to break up your query to squeeze a little more performance. I don't know if you are using …</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58971/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58971/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql/read.awp">Slow Running SQL Query (HFSQL)</source><title>Re: Slow Running SQL Query (HFSQL)</title></item><item><author>guest</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58965/read.awp</comments><pubDate>4 Aug 2016 15:05:00 Z</pubDate><description>Hi David,&#13;
&#13;
I totally agree on that part...&#13;
&#13;
I wrote a sql "like" engine a few years back (in windev 5.5), and that was the f…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58965/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58965/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql/read.awp">Slow Running SQL Query (HFSQL)</source><title>Re: Slow Running SQL Query (HFSQL)</title></item><item><author>guest</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58957/read.awp</comments><pubDate>3 Aug 2016 20:54:00 Z</pubDate><description>Hi Fabrice&#13;
Yeah, it sort of makes sense to me except that all the selection clauses are AND so I would have thought it would be…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58957/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58957/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql/read.awp">Slow Running SQL Query (HFSQL)</source><title>Re: Slow Running SQL Query (HFSQL)</title></item><item><author>guest</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58956/read.awp</comments><pubDate>3 Aug 2016 14:54:00 Z</pubDate><description>Hi David,&#13;
&#13;
the NOT case makes sense to me...&#13;
&#13;
When you do Var=Value, using an index is easy, because you are looking for ONE…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58956/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58956/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql/read.awp">Slow Running SQL Query (HFSQL)</source><title>Re: Slow Running SQL Query (HFSQL)</title></item><item><author>guest</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58943/read.awp</comments><pubDate>3 Aug 2016 07:29:00 Z</pubDate><description>Hi&#13;
I was just playing around on another very similar query which runs OK and noticed that the only substantial difference is th…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58943/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58943/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql/read.awp">Slow Running SQL Query (HFSQL)</source><title>Re: Slow Running SQL Query (HFSQL)</title></item><item><author>guest</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58941/read.awp</comments><pubDate>3 Aug 2016 05:53:00 Z</pubDate><description>Hi King&#13;
Yes, they're indexed and on queries that don't have a range of register ids, we get pretty well instant response. It's …</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58941/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58941/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql/read.awp">Slow Running SQL Query (HFSQL)</source><title>Re: Slow Running SQL Query (HFSQL)</title></item><item><author>guest</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58944/read.awp</comments><pubDate>3 Aug 2016 05:42:00 Z</pubDate><description>Hi&#13;
&#13;
Did you index alhead_linkid and sysid for a quick inner join&#13;
or they go for sequential inner join for searching that coul…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58944/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58944/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql/read.awp">Slow Running SQL Query (HFSQL)</source><title>Re: Slow Running SQL Query (HFSQL)</title></item><item><author>guest</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58939/read.awp</comments><pubDate>3 Aug 2016 05:36:00 Z</pubDate><description>Hi Fabrice&#13;
Just tried that and no difference I'm afraid. I'm wondering if it has something to do with the fact that I have seve…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58939/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58939/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql/read.awp">Slow Running SQL Query (HFSQL)</source><title>Re: Slow Running SQL Query (HFSQL)</title></item><item><author>guest</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58933/read.awp</comments><pubDate>2 Aug 2016 16:15:00 Z</pubDate><description>Hi David,&#13;
&#13;
I am wondering if the problem does not come from the group by clause.&#13;
&#13;
Could you try to add BranchID as the first…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58933/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql-58933/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/58922-slow-running-sql-query-hfsql/read.awp">Slow Running SQL Query (HFSQL)</source><title>Re: Slow Running SQL Query (HFSQL)</title></item></channel></rss>
