-2

Will joining on a binary data type be slower than e.g. char? E.g binary(10) vs char(10). Storage is 10 bytes for both.

5
  • 2
    Why do you suppose it might be slower (or faster)? What did your tests show?
    – mustaccio
    Nov 22 at 17:57
  • 1
    race your horses.
    – Dan Guzman
    Nov 22 at 17:59
  • @mustaccio: The reason why I think binary might be slower is because I have a query that joins on this data type and I cannot identify other problems with the query so thought it could be related to this.
    – xhr489
    Nov 22 at 19:04
  • 2
    Ah, the famous X-Y Problem™! You might want to read this advice
    – mustaccio
    Nov 22 at 19:15
  • Have you looked at the actual execution plan? Please provide it via Paste The Plan.
    – J.D.
    Nov 22 at 21:23

1 Answer 1

1

From a theoretical perspective, doing an equality join of a BINARY(N) to another BINARY(N) should use less resources than the same thing with CHAR(N) substituted for BINARY(N) because the CHAR type has to deal with collation, while the BINARY type does not.

From a practical perspective, you're going to have to do a big query and measure the resource usage with Extended Events or Profiler. Remember to run each instance multiple times and discard the first.

Not the answer you're looking for? Browse other questions tagged or ask your own question.