Where to query database in a module
You've got two options, depending on your needs


Static cache - data is built once during a single request and re-used where needed. Your query will run once but once only on every related request. See drupal_static() for example usages.
Backend cache - the results of your database query are cached, and you query the cache bins for the data instead of your database table. Your query will be run once only, until the cache is invalidated, when it'll obviously need to be run again. You'll still incur the overhead of querying the cache, so if your cache is database-based, this may or may not be worth it, depending on the size and complexity of your data. With this method you'll also need to think about how/when/if you invalidate the cache to get fresh data. See the Cache API docs for examples.