Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce column cache per connection #1744

Merged
merged 1 commit into from
Aug 7, 2018

Conversation

yahonda
Copy link
Collaborator

@yahonda yahonda commented Aug 1, 2018

#1490 removed Oracle enhanced adapter own column cache feature
to use Rails db:schema:cache:dump. However, it caused slower performance
about metadata search, such as column information.

This commit restores Oracle enhanced adapter own column cache feature.
It used to be class level caching, it is connection level caching now
since it is much easier and cleaner than class level ones.

Related to #1720

@yahonda yahonda requested a review from koic August 1, 2018 11:42
@yahonda
Copy link
Collaborator Author

yahonda commented Aug 1, 2018

@koic I'd like you to review this pull request since this implementation just works, but does not look good.

https://github.com/yahonda/oracle-enhanced/blob/4a1ed1116b3027896c113531b9ce61764efdf891/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb#L159-L170

        def columns(table_name)
          table_name = table_name.to_s
          if @columns_cache[table_name]
            @columns_cache[table_name]
          else
            @columns_cache[table_name] =
              column_definitions(table_name).map do |field|
              new_column_from_field(table_name, field)
            end
          end
          @columns_cache[table_name]
        end

Reasons:

Any feedbacks are welcomed.

@koic
Copy link
Collaborator

koic commented Aug 3, 2018

Sure thing. I will look it next week. Please wait a moment.

end
end
@columns_cache[table_name]
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using super to transfer to AR::ConnectionAdapters::SchemaStatements#columns(table_name) as follows?

         def columns(table_name)
           table_name = table_name.to_s
           if @columns_cache[table_name]
             @columns_cache[table_name]
           else
+            @columns_cache[table_name] = super(table_name)
-            @columns_cache[table_name] =
-              column_definitions(table_name).map do |field|
-              new_column_from_field(table_name, field)
-            end
           end
-          @columns_cache[table_name]
         end

There will be no duplication of implementation with super class.

@koic
Copy link
Collaborator

koic commented Aug 7, 2018

Copy and paste super method implementation

I wrote a comment on https://github.com/rsim/oracle-enhanced/pull/1744/files#r208188648.

@columns_cache[table_name] appears many times.

On the other hand. I don't have an idea to this dup codes...

@yahonda
Copy link
Collaborator Author

yahonda commented Aug 7, 2018

@koic Thanks for the review. Making use of super looks good. I have made a change as you suggested and squashed.

else
@columns_cache[table_name] = super(table_name)
end
@columns_cache[table_name]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this explicit return value line is unnecessary. The return value is determined by L163 or L165.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Updated.

rsim#1490 removed Oracle enhanced adapter own column cache feature
to use Rails `db:schema:cache:dump`.  However, it caused slower performance
about metadata search, such as column information.

This commit restores Oracle enhanced adapter own column cache feature.
It used to be class level caching, it is connection level caching now
since it is much easier and cleaner than class level ones.

Related to rsim#1720
@yahonda yahonda merged commit 67ccf8a into rsim:master Aug 7, 2018
@yahonda yahonda deleted the restore_column_cache branch August 7, 2018 12:32
@koic
Copy link
Collaborator

koic commented Aug 7, 2018

Thanks for fixing pragmatic issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants