diff --git a/app/models/user.rb b/app/models/user.rb
index 47439ce4b004d7e908993a614e7b964a112937dc..9d75bb3aeb4c7a953cb6ae2de5aed9cbe91f1923 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -404,10 +404,8 @@ class User < ActiveRecord::Base
 
   def owned_projects
     @owned_projects ||=
-      begin
-        namespace_ids = owned_groups.pluck(:id).push(namespace.id)
-        Project.in_namespace(namespace_ids).joins(:namespace)
-      end
+      Project.where('namespace_id IN (?) OR namespace_id = ?',
+                    owned_groups.select(:id), namespace.id).joins(:namespace)
   end
 
   # Team membership in authorized projects