Redis SLOWLOG get output - redis

The slowlog get got the following result. The size of the Hr:v1:Account and WorkflowService:v1:Summary:2022-05-25 are 64MB and 24MB respectively. Are the speeds too slow? What can be be checked?
> slowlog get
1) 1) "482470"
2) "1659542506"
3) "89761"
4) 1) "HVALS"
2) "Hr:v1:Account"
5) "10.0.121.89:54200"
6) "workflow-service-5cb4dd586f-lgk2t"
2) 1) "482469"
2) "1659542040"
3) "90711"
4) 1) "HVALS"
2) "Hr:v1:Account"
5) "10.0.121.87:51498"
6) "workflow-service-5cb4dd586f-b5hsv"
3) 1) "482468"
2) "1659541603"
3) "92399"
4) 1) "HVALS"
2) "Hr:v1:Account"
5) "10.0.121.89:54200"
6) "workflow-service-5cb4dd586f-lgk2t"
4) 1) "482467"
2) "1659541138"
3) "91147"
4) 1) "HVALS"
2) "Hr:v1:Account"
5) "10.0.121.87:51498"
6) "workflow-service-5cb4dd586f-b5hsv"
5) 1) "482466"
2) "1659540701"
3) "91263"
4) 1) "HVALS"
2) "Hr:v1:Account"
5) "10.0.121.89:54176"
6) "workflow-service-5cb4dd586f-lgk2t"
6) 1) "482465"
2) "1659540235"
3) "91721"
4) 1) "HVALS"
2) "Hr:v1:Account"
5) "10.0.121.87:51490"
6) "workflow-service-5cb4dd586f-b5hsv"
7) 1) "482464"
2) "1659539799"
3) "81112"
4) 1) "HVALS"
2) "Hr:v1:Account"
5) "10.0.121.89:54166"
6) "workflow-service-5cb4dd586f-lgk2t"
8) 1) "482463"
2) "1659539790"
3) "17437"
4) 1) "HGETALL"
2) "WorkflowService:v1:Summary:2022-05-25"
5) "10.0.121.87:51462"
6) "workflow-service-5cb4dd586f-b5hsv"
9) 1) "482462"
2) "1659539721"
3) "16732"
4) 1) "HGETALL"
2) "WorkflowService:v1:Summary:2022-05-25"
5) "10.0.121.87:51462"
6) "workflow-service-5cb4dd586f-b5hsv"
10) 1) "482461"
2) "1659539332"
3) "90810"
4) 1) "HVALS"
2) "Hr:v1:Account"
5) "10.0.121.87:51462"
6) "workflow-service-5cb4dd586f-b5hsv"

HGETALL and HVALS are both O(N) where N is the size of the underlying hash, 90ms does not seem unreasonable given the rather large size of the hahses, particularly if those hashes many tiny fields rather than a few large fields that you are trying to pull back (that's just the time in redis, I imagine that there's a lot of time spent over the network pulling back that much data). If you need this to operate quicker, the main question to answer is "do I need all of the data I'm getting back from Redis?" If not, you can modify your access pattern to access via HMGET so you can pull back a more surgical subset of the data that you actually need.

Related

Random number with VBA

I am trying to create random numbers in within normal distribution given random probabilities in a range. My code is the following:
Range(Cells(2, 1), Cells(RandomNumbers + 1, 1)) = WorksheetFunction.Norm_S_Inv(Rnd)
Where RandomNumbers is just a value in another cell. The problem is that if RandomNumbers is equal to, lets say, 10 then VBA fills the same random number in all 10 cells. How do I make every number different in every cell?
Make it a loop:
Dim cell as Range
For Each cell In Range(Cells(2, 1), Cells(RandomNumbers + 1, 1))
cell.Value = WorksheetFunction.Norm_S_Inv(Rnd)
Next

syntax for comparing values

Anyone know what is wrong with following code?:
I have extra parenthesis to compare the difference in value!
(Sheet1.Cells(i - 1, "H").Value - Sheet1.Cells(i, "H").Value) < 60 / 86400

New to VBA- runtime error 6, script stops at blank cells instead of looping

Recently started working with VBA. Youtube and this forum have been excellent help so far. However, my problem is this:
Private Sub CommandButton1_Click()
Dim i As Integer
i = 1
Do While Sheet2.Cells(i, 1).Value <> 0
Sheet3.Cells(i, 1).Value = Sheet2.Cells(i, 1)
i = i + 1
Loop
Do While Sheet2.Cells(i, 10).Value <> 0
Sheet3.Cells(i, 4).Value = Sheet2.Cells(i, 10)
i = i - 1
Loop
Do While Sheet2.Cells(i, 6).Value <> 2
Sheet3.Cells(i, 3).Value = Sheet2.Cells(i, 6)
i = i + 1
Loop
End Sub
This script populates information in the correct sheet as well as the correct columns, at least until it encounters an empty cell from Sheet2. At this point is moves on to the next "Do While" instead of referring to the next non blank cell.
I've also encountered a Runtime Error 6- Overflow with this specific line:
Do While Sheet2.Cells(i, 6).Value <> 2
Sheet3.Cells(i, 3).Value = Sheet2.Cells(i, 6)
i = i + 1 <<<<----- ERROR??
I'm fairly certain that the Overflow Error is a result of Dim i as Integer vs. Dim i as String, but then again I've pretty much but working by trial and error, moving portions of script around and playing with expressions/functions.
As mentioned before I'm new to VBA. I'm also the kind of guy that learns by doing as well. I've looked all over different forums, youtube videos, etc. trying to create a script that works the way I want it to.
UPDATE
Thanks for the quick help and recommendations. I realized I didn't give near enough information in my first post.
1.) I don't need/want to leave an empty cell on sheet3. The script is now looping but not skipping over blanks if that makes sense?
For example:
doing need to do
101 101
102 102
104
104 105
105 106
106
I'm stil running off the end of the world as well so to speak. For some reason the Debug Function is bringing up this line
i = i + 1
2.) the line:
Do While Sheet2.Cells(i, 6).Value <> 2
Sheet3.Cells(i, 3).Value = Sheet2.Cells(i, 6)
is supposed to recognize a column of text not numbers. Not exactly sure if this is having an effect on anything
Thanks again everyone.
UPDATE 3:
I've got rid of the Error Messages and corrected all the expressions in the script. Also, I found that instead of using Do Until....... And........ had zero results. I had to go back to Do While and substitute an Or statement vs. the former.
So far the script is working better than I had expected. Thank You all for the help and insight.
Good news aside, I still need to figure out how to compose an "IF" statement so that the script will skip over blank cells in sheet2.cells(i, 1) and not import present values for that row in the 2 adjacent columns
Here is the current and running script:
Private Sub CommandButton1_Click()
Dim i As Long
i = 3
Do While (Not IsEmpty(Sheet2.Cells(i, 10))) Or (Sheet3.Cells(i, 4).Value <> 0)
Sheet3.Cells(i, 4).Value = Sheet2.Cells(i, 10).Value
i = i + 1
Loop
i = 3
Do While (Not IsEmpty(Sheet2.Cells(i, 1))) Or (Sheet3.Cells(i, 1).Value <> 0)
Sheet3.Cells(i, 1).Value = Sheet2.Cells(i, 1).Value
i = i + 1
Loop
i = 3
Do While (Not IsEmpty(Sheet2.Cells(i, 6))) Or (Sheet3.Cells(i, 3).Value <> 0)
Sheet3.Cells(i, 3).Value = Sheet2.Cells(i, 6).Value
i = i + 1
Loop
End Sub
Thank you again everyone. Hope I can return the favor in the near future.
A few thoughts:
As #dgorti said, make sure to set i before each Do loop to be the index of the row you want to start with.
Dim any integer value as Long, not Integer. Long is 32 bits; Integer is 16.
To skip over empty cells, use IsEmpty. For example, in your first loop: Edited
Do Until (Not IsEmpty(Sheet2.Cells(i, 1))) and (Sheet2.Cells(i, 1).Value = 0)
Edit And, as #A.S.H. points out, you should also range-check i. Since VBA doesn't have short-circuit operators, I would do that at the end of your loop:
Do ...
... 'vvvvv representable in a Long
If i = 65536 Then Exit Do ' Or If i = 1... for loops that count down
i = i + 1
Loop
That way you never run off the end.
Edit I fixed the test above — you want to run until you hit a non-empty cell with a value of 0, right? So Do Until (which is a real thing :) ) loops until exactly that condition holds. The Not IsEmpty() prevents the test against 0 from giving the wrong result on blank cells.

search for similar phone numbers in a column

I have a collection of phone numbers in a column. I want to identify similar ones in the column. The similarity rule would be the first 8 digits are the same and the last two digits are in sequence (at least 3 numbers).
For example,
8601116612
8601116613
8601116614
The three numbers above should be identified as being similar. How can I do this in VBA?
Alrighty, this was kinda frustrating, but here it is:
Sub findSims()
Dim i, j, rc, rc1 As Double
Dim m, z As Double
i = 1
m = 0
z = 0
Do While Cells(i, 1) <> ""
' calculate the value of the last two digits
' for educational reasons one calculation
rc = Right(Cells(i, 1), 2)
rc1 = Right(Cells(i + 1, 1), 2) - 1
' .. and one direct comparation ..
' .. of the first 8 digits and afterwards the first two
If Left(Cells(i, 1), 8) = Left(Cells(i + 1, 1), 8) Then
If rc = rc1 Then
' there are two counters because we have to wait until we have three similar numbers
m = m + 1
z = z + 1
Else
' if the similarities stop, we kill m
m = 0
' we use z to write this cutie of a sentence (you can insert here whatever you like)
If z > 1 Then
Cells(i, 2) = "The Cells from A" & i & " to A" & (i - z) & " are similar."
End If
z = 0
End If
End If
' increment i and the job is done
i = i + 1
Loop
End Sub
This seems kinda clunky and theres probably a better solution, but thats the best I came up with. Have fun.

How can I find the rightmost column in a 2D array in vb.net?

How can I find the rightmost column in a 2D array in vb.net? I currently have a 2 dimensional array as follows
Dim intArray(0 To 34, 0 To 57) As Integer
I want to find the right most column (highest second number), and UBound only returns the last row. How can I do this?
Specify, the dimension in UBound():
numColumns = UBound(intArray, 2) + 1 (assumes zero based)
Another example:
Dim A(1 To 50, 0 To 10, -3 To 9)
Value
UBound(A, 1) 50
UBound(A, 2) 10
UBound(A, 3) 9