-
Notifications
You must be signed in to change notification settings - Fork 14
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
Postgres performance #361
Postgres performance #361
Conversation
Up to an extent, I converted the sql queries to sqlalechemy expressions, but some of them are really long and complicated to convert. But if the reviewers see it essential, I will try to convert all the queries to sqlalchemy expressions. |
Of course a unittest will be added. I have to first figure out how to create a postgres database via a github workflow. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
pyiron_base/database/performance.py
Outdated
""" | ||
stmt = select(func.count()).select_from(self._stat_view) | ||
result = conn.execute(stmt) | ||
self._performance_dict['total num. connection'] = result.fetchone()[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this code hard to read. From my perspective it would be easier to return the entry rather than writing to the dictionary. This also simplifies debugging later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I would like each function to return a sub dictionary and then use dict.update()
to merge them in the end. https://python-reference.readthedocs.io/en/latest/docs/dict/update.html This way we can debug the individual functions, look at the output they return. Following the zen of python: Explicit is better than implicit. https://www.python.org/dev/peps/pep-0020/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the links. Now each method returns a dictionary which is used at the end to update self._performance_dict
.
@muh-hassani I added a few comments but apart from those I guess it would be great to merge this functionality soon. |
I like the class still I can not stop wondering if it would not be easier for the user to have just one function?
This function could be defined as:
|
I agree, it makes the usage much easier. I have done it, the way you suggested. |
@jan-janssen, if you approve the current status of this PR, I can merge it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jan-janssen, if you approve the current status of this PR, I can merge it.
Looks good to me.
The new class is intended to monitor important parameters of pyiron central database. Here, it is assumed that the database is a Postgresql database. The final data is presented as pandas dataframe.
the use case should be :
The references for the queries can be found:
[1] https://russ.garrett.co.uk/2015/10/02/postgres-monitoring-cheatsheet/
[2] https://pgdash.io/blog/essential-postgres-monitoring-part2.html
[3] https://wiki.postgresql.org/wiki/Index_Maintenance