Forum Replies Created

Viewing 15 posts - 226 through 240 (of 1,419 total)

  • Reply To: Calculating Prime Numbers With One Query

    Ok the proof by induction is acceptable

    If 2 doesn't add or subtract from what's being measured that's a good reason to get rid of it imo

    For my projects the upgrade...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Calculating Prime Numbers With One Query

    Jonathan AC Roberts wrote:

    including p.N%6 IN(1, 2) It does increase the performance a bit, so I would argue it is appropriate. It changes the number of prime candidates from n/2 (odd numbers)...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Calculating Prime Numbers With One Query

    Jonathan AC Roberts wrote:

    Shifting gears, there's a slight enhancement to Steve's algorithm that reduces the execution time from 2 seconds to 1.8 seconds. This improvement involves testing whether the prime candidate is...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Calculating Prime Numbers With One Query

    That's the article which had shaped my low expectations.  Good to know it's been improved.  It's also interesting Jonathan used GENERATE_SERIES in place of the non-itvf method of TOP and...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Calculating Prime Numbers With One Query

    These are great comparisons.  The so-far winning code was jointly arrived at.  Interesting in a straight comparison GENERATE_SERIES appears faster than fnTally

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Calculating Prime Numbers With One Query

    At the moment I don't have access to an instance of SQL 2022 to test with.  That could change in the near future tho.  For now I was just fishing...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Calculating Prime Numbers With One Query

    Why mess with fnTally when what we really need is for Jeffrey to rewrite the query?  Ha, then we also get a baseline of the functions.  Also how does the...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Calculating Prime Numbers With One Query

    Jonathan AC Roberts wrote:

    Each number you test for primality needs O(sqrt(n)*n) calculations, so it will slow down for larger numbers. Also, if you increase @n to 10 times its previous value each...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Calculating Prime Numbers With One Query

    Jonathan AC Roberts wrote:

    You only need to test up to the square root of a number to test for primality, which is quite a saving:

    declare @n   ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Calculating Prime Numbers With One Query

    Oh you're right.  This is not the final version but I'm not finding my notes on this.   Iirc if you follow the links it leads to a SQLlite script with...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Calculating Prime Numbers With One Query

    For exhaustive methods it's quicker to only look at odd numbers.  There was a Youtube video a little while ago where they compared all different programming languages to determine which...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Display columns from multiple rows in single

    Ok thanks.  Yeah maybe I misread this one.  When there are spaces in object labels it causes flashbacks to a difficult job

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Display columns from multiple rows in single

    Is the QUOTENAME to make the sample data?  🙂

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Display columns from multiple rows in single

    Looking at the first picture above the ordering of the Hours doesn't seem clear.  Is it ASCENDING by [Run Start Time]?  In the output, when the System value equals 6,...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: How Can I Speed This Query Up?

    Why settle a tie using query logic, what about a unique index?  Some or one of those could be helpful.  A table containing holidays to exclude could be useful too. ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

Viewing 15 posts - 226 through 240 (of 1,419 total)