there isnt an optimised way, and you could get all values yourself and use a dictionary or hashset as boroda suggests or
you can use:
Library_QueryLookupTable("Artist", "", null)
or
Library_QueryLookupTable("AlbumArtist", "", null)
and to get the values
Library_QueryGetLookupTableValue(null)
which returns a string formatted as:
artist1\0count1\0\0artist2\0\0etc