How to speed up Xcode indexing?

You can disable indexing by doing:
defaults write com.apple.dt.XCode IDEIndexDisable 1
(this works for me, but I think you do need to restart Xcode)

It’s very annoying though as this is a global settings, and I’d really like to have indexing working in general. I had to do it though as XCode took >40Gb of RAM before my machine ran out of space and crashed.