let’s take a look at basic queries and similarity search. Now before you can do queries against your vector data, you have to insert the data first. So I wanted to show you an example of inserting several rows of vectors. Now in this case, each vector represents some sort of data point. And in some cases, they have more dimensions than in others. So as an example, that first row of inserts, 1.1 comma 2.7 comma 3.14, that has three dimensions. Further down with the 7.3, that only has a single dimension. Now after you insert data, then you can select the data. And in this case, if we select star from the T1 table, it would look like this. You’ll notice that the data is returned in scientific notation. Bear in mind, you could use a function such as to number in order to return a more readable, friendly version of the value. Now let’s talk about some of the basic rules. You’re not allowed to use comparison operations between vectors. If you do, you’re going to get an error message back. And it’s going to tell you that you cannot use vector type as comparison key. We’ll show you another example. Here we’re using the less than or equal to sign. And again, this is going to return the following error. Now let’s take a look at similarity search. Now vector data is usually unevenly distributed and clustered. And clustered means that it is in groups. So you might have groupings of houses, for instance, in a neighborhood that are all around the same price. Now, with similarity searches, you might need to search for nearest neighbors, which is going to be an ordered list by rank. Searches can be approximate, or they can be specific. Now, in this example, you’ll notice that we have different types of animals. We have wolf, dog, puppy, cat, kitten, lion, and elephant. And if we’re talking about nearest neighbors, we see that a dog is more similar to a wolf and is less similar to a kitten. So if we’re looking for the nearest neighbors, we might want to look for dog, puppy, wolf, for instance. And that represents data that makes sense for something that’s relatable to a dog. Now with the exact similarity search, this is going to calculate the query vector distance to all other vectors. And exact similarity searches are also called flat searches. They do give you the most accurate results. But the trade off is that these take longer. Although the search quality is perfect. Now when you do vector distance queries, you use the vector distance function. And the vector distance function uses something that we call a metric as an optional parameter. Now, in this example, we’re going to show you Euclidean and Euclidean squared distances, cosine similarity, dot product similarity, Manhattan distance, Hamming similarity. Now think about it like this. If you’re talking about the distance between a couple of points, what if you’re walking in a city and there are buildings between the two points? You can’t do a straight line between those points. You have to maybe walk around a block or maybe walk around several blocks to get to the location. So that would be an example of Manhattan distance metric. And so you would want to use the metric that makes sense for your particular data set. So here, we have an exact similarity search. And we are searching for the three nearest neighbors to a particular query point. So the query point is vq. And we want to find the three nearest neighbors. This is called a k nearest neighbor search. And we’re highlighting where on this representation those closest neighbors lie to the query point. Now if we wanted to use the Euclidean metric, we would do a SELECT statement that looks something like this. Select the doc ID from the vector tab table. Order by vector distance, and there’s that vector distance function. Now we’re supplying a column called embedding, which is the column that has the embedding, or rather the vector data type. And then we have an input query vector. And then that final parameter is the Euclidean metric. Notice that we are fetching exact first 10 rows only. By the way, the exact keyword would be optional. Now, this is bringing back the 10 closest neighbors using the Euclidean metric. Now, if we leave off the Euclidean metric keyword, then it’s going to use Euclidean squared distance as the default. And so here is another example using the same column, the same table, the same fetch first 10 rows only. So we’re bringing back the 10 closest neighbors. But this time, we’re using the Euclidean squared distance metric. The Euclidean squared distance metric is going to be quicker because it doesn’t have to calculate the squared distance. Now, if you want to do approximate similarity search, that is going to involve the use of vector indexes. And in order to create vector indexes, you do have to enable the vector pool in the SGA. These can be more efficient because they usually operate quicker than exact similarity searches. They can be less accurate. As an example, if you’re doing an exact similarity search, it’s going to be perfect on the results. However, if you use approximate similarity search, it might be 80% accurate. Now you can also provide the parameter as far as your accuracy metric. So if you wanted it to be 95% accurate, you can provide that as input. And that is what I’m talking about here with the target accuracy. So let’s take a look at that in a visual example. So here we have the input, the vq, the query. And if we are looking at an exact similarity search, you’ll notice that it finds the five closest neighbors. And we can visually see that with the gray cloud that’s circling those five other black X’s. Now if we did an approximate search, then notice that we find four out of five of those nearest neighbors. And in this case, you see that that is 80% accurate. So as we mentioned, approximate similarity search uses vector indexes. We have two different indexes that are supported. We have Hierarchical Navigable Small World, or HNSW index. And we have Inverted File Flat, or IVF index. We’re going to show you an example of creating each one of these types of indexes. Here, we’re creating an HNSW index. Create vector index. And the name is going to be galaxies HNSW on the galaxies table, on the vector column, which is called embedding. Organization in memory. Neighbor graph distance cosine with target accuracy 95. And there’s that target accuracy metric that I talked about earlier. And then when we go in and do a select, then it’s going to use the index in order to return the result set. Now in this example, Iám going to show you how to create an IVF or inverted file flat index. Create vector index galaxies IVF IDX on galleries, or sorry, galaxies. Again, the embedding column, which is a vector type. Organization neighbor partitions distance cosine with target accuracy 95. And then when we do that SELECT statement there, it does return the first three rows or the three closest neighbors. And this will use the IVF index in this example.
Continue reading...Recent Posts
Tags
11g
12c
ace
aioug
blog
blog issues
Certification
chapter
checkpoint
cloud
dirty
download
em
event
Fun
general
Grid Console
happynewyear
ilm
imu
internal
internals
introduction
lpu
nic
OCP
OEL
oracle cloud
otn
otntechnet
otnyathra
ou
packt
private redo
promotion
rac
Review
sangam
scn
sqlplus
techday
training
twitter
virtualbox
wordpress
Archives
- January 2026 (5)
- May 2025 (9)
- April 2025 (4)
- March 2025 (1)
- February 2025 (9)
- January 2025 (3)
- December 2024 (9)
- November 2024 (11)
- May 2024 (4)
- April 2024 (2)
- March 2024 (3)
- February 2024 (13)
- January 2024 (4)
- June 2023 (1)
- May 2023 (4)
- April 2023 (3)
- March 2023 (4)
- February 2023 (8)
- January 2023 (15)
- October 2022 (3)
- April 2022 (1)
- March 2022 (4)
- February 2022 (6)
- January 2022 (6)
- October 2021 (1)
- August 2021 (4)
- April 2021 (5)
- March 2021 (3)
- February 2021 (1)
- January 2021 (6)
- December 2020 (1)
- May 2020 (1)
- April 2020 (9)
- March 2020 (5)
- February 2020 (6)
- January 2020 (4)
- March 2019 (1)
- May 2018 (1)
- July 2017 (1)
- June 2017 (1)
- March 2017 (1)
- October 2016 (1)
- September 2016 (2)
- March 2016 (3)
- December 2015 (2)
- January 2015 (2)
- August 2014 (1)
- July 2014 (3)
- June 2014 (2)
- May 2014 (1)
- April 2014 (3)
- March 2014 (2)
- February 2014 (1)
- January 2014 (1)
- November 2013 (1)
- October 2013 (1)
- September 2013 (2)
- July 2013 (2)
- June 2013 (4)
- February 2013 (4)
- January 2013 (1)
- December 2012 (2)
- November 2012 (3)
- October 2012 (1)
- September 2012 (1)
- July 2012 (1)
- June 2012 (2)
- April 2012 (1)
- March 2012 (2)
- February 2012 (1)
- December 2011 (3)
- October 2011 (1)
- September 2011 (1)
- August 2011 (1)
- July 2011 (2)
- June 2011 (1)
- April 2011 (3)
- February 2011 (1)
- January 2011 (1)
- December 2010 (2)
- October 2010 (1)
- September 2010 (2)
- July 2010 (4)
- June 2010 (2)
- May 2010 (2)
- April 2010 (2)
- March 2010 (4)
- February 2010 (4)
- January 2010 (2)
- December 2009 (2)
- October 2009 (2)
- August 2009 (5)
- July 2009 (3)
- June 2009 (1)
- April 2009 (2)
- March 2009 (5)
- February 2009 (5)
Console
Recent Posts
Tags
11g
12c
ace
aioug
blog
blog issues
Certification
chapter
checkpoint
cloud
dirty
download
em
event
Fun
general
Grid Console
happynewyear
ilm
imu
internal
internals
introduction
lpu
nic
OCP
OEL
oracle cloud
otn
otntechnet
otnyathra
ou
packt
private redo
promotion
rac
Review
sangam
scn
sqlplus
techday
training
twitter
virtualbox
wordpress
Recent Comments
- Mehmet on Failed To Load Selinux Policy, Freezing[Solved]….
- ananya patel on Book Review, Oracle Database 11g-Underground Advice For DBAs….
- Tony on Failed To Load Selinux Policy, Freezing[Solved]….
- Pankaj on Failed To Load Selinux Policy, Freezing[Solved]….
- Satish on Oracle Cloud Infrastructure (OCI) Fundamentals Part 3 – Storage Services….
- Nguyen on Failed To Load Selinux Policy, Freezing[Solved]….
- rajantha on Failed To Load Selinux Policy, Freezing[Solved]….
- Rajantha on Failed To Load Selinux Policy, Freezing[Solved]….
Archives
- January 2026 (5)
- May 2025 (9)
- April 2025 (4)
- March 2025 (1)
- February 2025 (9)
- January 2025 (3)
- December 2024 (9)
- November 2024 (11)
- May 2024 (4)
- April 2024 (2)
- March 2024 (3)
- February 2024 (13)
- January 2024 (4)
- June 2023 (1)
- May 2023 (4)
- April 2023 (3)
- March 2023 (4)
- February 2023 (8)
- January 2023 (15)
- October 2022 (3)
- April 2022 (1)
- March 2022 (4)
- February 2022 (6)
- January 2022 (6)
- October 2021 (1)
- August 2021 (4)
- April 2021 (5)
- March 2021 (3)
- February 2021 (1)
- January 2021 (6)
- December 2020 (1)
- May 2020 (1)
- April 2020 (9)
- March 2020 (5)
- February 2020 (6)
- January 2020 (4)
- March 2019 (1)
- May 2018 (1)
- July 2017 (1)
- June 2017 (1)
- March 2017 (1)
- October 2016 (1)
- September 2016 (2)
- March 2016 (3)
- December 2015 (2)
- January 2015 (2)
- August 2014 (1)
- July 2014 (3)
- June 2014 (2)
- May 2014 (1)
- April 2014 (3)
- March 2014 (2)
- February 2014 (1)
- January 2014 (1)
- November 2013 (1)
- October 2013 (1)
- September 2013 (2)
- July 2013 (2)
- June 2013 (4)
- February 2013 (4)
- January 2013 (1)
- December 2012 (2)
- November 2012 (3)
- October 2012 (1)
- September 2012 (1)
- July 2012 (1)
- June 2012 (2)
- April 2012 (1)
- March 2012 (2)
- February 2012 (1)
- December 2011 (3)
- October 2011 (1)
- September 2011 (1)
- August 2011 (1)
- July 2011 (2)
- June 2011 (1)
- April 2011 (3)
- February 2011 (1)
- January 2011 (1)
- December 2010 (2)
- October 2010 (1)
- September 2010 (2)
- July 2010 (4)
- June 2010 (2)
- May 2010 (2)
- April 2010 (2)
- March 2010 (4)
- February 2010 (4)
- January 2010 (2)
- December 2009 (2)
- October 2009 (2)
- August 2009 (5)
- July 2009 (3)
- June 2009 (1)
- April 2009 (2)
- March 2009 (5)
- February 2009 (5)

Recent Comments