<div dir="ltr"><br /><div class="gmail_extra"><br /><br /><div class="gmail_quote">On Mon, Oct 14, 2013 at 10:55 AM,
TomLane <span dir="ltr"><<a href="mailto:tgl@sss.pgh.pa.us" target="_blank">tgl@sss.pgh.pa.us</a>></span>
wrote:<br/><blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div
class="im">SorooshSardari <<a href="mailto:soroosh.sardari@gmail.com">soroosh.sardari@gmail.com</a>> writes:<br
/>> I developed a new character string type, named myvarchar.<br /> > Also an operator class for btree is
added.<br/></div><div class="im">> PROBLEM:<br /> > When I executed a query with where clause on 'mine' column,
PGdoes not use<br /> > index.<br /><br /></div>Most likely you got the opclass definition wrong. Since you've shown
us<br/> no details of what you did, it's hard to speculate about just how. But<br /> note that varchar itself is a
prettybad model for a user-added datatype,<br /> because it has a special symbiotic relationship with type "text" (to
wit,<br/> it has no operators of its own but uses text's operators via implicit<br /> casts). To get to a working
independentdatatype like this, you'd need<br /> to pick the right aspects of each of text and varchar to clone. So
my<br/> unfounded speculation is you didn't do that just right.<br /><br /> regards, tom
lane<br/></blockquote></div><br /></div><div class="gmail_extra"><br /></div><div class="gmail_extra" style="style">As
Tomsaid, I did something wrong when I was creating new operators.</div><div class="gmail_extra" style="style">The
RESTRICTparameter is forgotten. Since all varchar operations</div><div class="gmail_extra" style="style">redirected to
textoperators, hence my operators must be like</div><div class="gmail_extra" style="style">operators of type
text.</div><divclass="gmail_extra" style="style"><br /></div><div class="gmail_extra" style="style"> I used following
commandto find text operator:</div><div class="gmail_extra" style="style"><div class="gmail_extra"><br /></div><div
class="gmail_extra">select* from pg_operator where oprleft = 25 </div><div class="gmail_extra"><span class=""
style="white-space:pre"></span>and oprright = 25</div></div><div class="gmail_extra" style="style"><br /></div><div
class="gmail_extra"style="style">P.S : 25 is oid of text type.</div><div class="gmail_extra" style="style"><br
/></div><divclass="gmail_extra" style="style">Cheers,</div><div class="gmail_extra" style="style">Soroosh
Sardari</div></div>