-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
perf: new column Posting Datetime in SLE to optimize stock ledger related queries #39800
perf: new column Posting Datetime in SLE to optimize stock ledger related queries #39800
Conversation
af442b7
to
244a385
Compare
3b9485f
to
b58cc8c
Compare
@rohitwaghchaure why closed? TZ issues? Those should be fixable. I can help if required. |
@ankush Will reopen after fixing TZ issues and test cases |
b58cc8c
to
c5684a3
Compare
c5684a3
to
7bed8a6
Compare
4d00d73
to
d700603
Compare
d700603
to
d80ca52
Compare
from | ||
`tabStock Ledger Entry` | ||
where | ||
item_code = %(item_code)s | ||
and warehouse = %(warehouse)s | ||
and is_cancelled = 0 | ||
and ( | ||
posting_date = %(posting_date)s and | ||
time_format(posting_time, %(time_format)s) = time_format(%(posting_time)s, %(time_format)s) | ||
posting_datetime = %(posting_datetime)s |
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.
This isn't same as before. The previous code was stripping milliseconds microseconds. We can convert this into two different conditions
posting_datetime >= time.replace(microseconds=0)
AND
posting_date < time.replace(microseconds=0) + timedelta(seconds=1)
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 have already tried this but the test case test_timestamp_clash is breaking because of this
erpnext/stock/stock_ledger.py
Outdated
|
||
if operator == "<=": | ||
# Add 1 second to handle millisecond for less than and equal to condition | ||
args["posting_datetime"] = add_to_date(args["posting_datetime"], seconds=1) |
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.
This will not work as args
is a dictionary you'll end up overriding the previous conditions?
Or is this supposed to work because of order by and limit?
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 it's working because of order by and limit, but maybe need to think of ms case.
3e89fe2
to
05e3cb4
Compare
05e3cb4
to
f04676a
Compare
314b127
to
a73ba2c
Compare
…ated queries (backport #39800) (#40004) * perf: new column posting datetime in SLE to optimize stock ledger related queries (cherry picked from commit d80ca52) # Conflicts: # erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py * test: test cases to test clash timestamp entries (cherry picked from commit f04676a) * chore: remove microsecond from posting_datetime (cherry picked from commit a73ba2c) * chore: fix conflicts --------- Co-authored-by: Rohit Waghchaure <rohitw1991@gmail.com>
# [15.15.0](v15.14.7...v15.15.0) (2024-02-28) ### Bug Fixes * add flags for repost to ensure correct accounting from India Compliance App ([7d14ecf](7d14ecf)) * amount label according to party type ([d541ba3](d541ba3)) * Cannot read properties of undefined (backport [#40081](#40081)) ([#40083](#40083)) ([53d943e](53d943e)) * capacity planning issue in the job card (backport [#40092](#40092)) ([#40101](#40101)) ([27703b5](27703b5)) * change label name ([824df72](824df72)) * check for pricing rules on item ([32d9642](32d9642)) * check_credit_limit on_update_after_submit of Sales Order ([83d7111](83d7111)) * communication_date in party dashboards (backport [#40005](#40005)) ([#40021](#40021)) ([4269ef8](4269ef8)) * Completed Work Orders report not working ([ca03e9c](ca03e9c)) * Cr/Dr notes with POS Payments ([2e07b03](2e07b03)) * currency symbol in landed cost voucher and material request (backport [#40138](#40138)) ([#40141](#40141)) ([57bb031](57bb031)) * Data too long for column 'serial_no' at row 1 (backport [#40098](#40098)) ([#40139](#40139)) ([9d19ec4](9d19ec4)) * default taxable value for item not found in item list ([7e43f6b](7e43f6b)) * delete PLE containing invoice in against ([190bd45](190bd45)) * do not make MR against raw materials of available sub assemblies (backport [#40085](#40085)) ([#40087](#40087)) ([cf5fa21](cf5fa21)) * Fiscal Year exception on demo data setup ([56ee843](56ee843)) * incorrect item name in MR (backport [#40018](#40018)) ([#40024](#40024)) ([9f8f3db](9f8f3db)) * Issues regarding asset cancellation and deletion ([8eb2f67](8eb2f67)) * negative stock error while making stock reconciliation (backport [#40016](#40016)) ([#40026](#40026)) ([c964c45](c964c45)) * on unreconciliation, update advance paid ([4d1f56c](4d1f56c)) * only check for delinked PLEs ([a75a69a](a75a69a)) * only consider contributed qty towards achieved targets ([194f46b](194f46b)) * parent warehouse checks in the production plan for sub-assemblies (backport [#40150](#40150)) ([#40157](#40157)) ([4784117](4784117)) * remove cancelled payment entry from Payment Period Based On Invoice Date ([72da308](72da308)) * remove cancelled payment entry from PPBOID report ([0be5203](0be5203)) * remove config for default bank account in test ([36b442a](36b442a)) * remove microsecond from posting datetime (backport [#40017](#40017)) ([#40022](#40022)) ([eaa3849](eaa3849)) * removed unwanted patch ([ee2d108](ee2d108)) * resolved conflict ([6928674](6928674)) * resolved conflict ([a0c0ab7](a0c0ab7)) * skip max discount validation for rate adjustment ([3b96aae](3b96aae)) * skip SO & DN validation for debit note ([cd42089](cd42089)) * Supplier users not able to see RFQ on the Portal (backport [#40161](#40161)) ([#40165](#40165)) ([6a63a6c](6a63a6c)) * timesheet per billed state edge case (backport [#40010](#40010)) ([#40029](#40029)) ([a543bf4](a543bf4)) * translatable columns in Sales Pipeline Analytics report ([1c5a7e2](1c5a7e2)) * type error for missing frm obj ([6b5e1cf](6b5e1cf)) * unique gl account for plaid bank accounts ([65853da](65853da)) * use correct variable name on hotfix branches ([0694fd1](0694fd1)) * use frm instead of cur_frm ([341f903](341f903)) * use serial batch fields for packed items (backport [#40140](#40140)) ([#40142](#40142)) ([1860399](1860399)) ### Features * show contributed qty in transaction summary ([38abfdb](38abfdb)) * update billed amount in PO and PR ([e7e8149](e7e8149)) ### Performance Improvements * new column Posting Datetime in SLE to optimize stock ledger related queries (backport [#39800](#39800)) ([#40004](#40004)) ([b9181e8](b9181e8))
Before Changes
577.667 Seconds (9.62 mins)
After Changes
11.514 Seconds (0.19 mins)
Fixed #38364